*
*/
-
+#ifndef __SLP_AIL_PG_H__
+#define __SLP_AIL_PG_H__
/**
- @ingroup SLP_PG
- @defgroup SLP_PG_APPLICATION INFORMATION LIBRARY AIL
- @{
+ @ingroup SLP_PG
+ @defgroup SLP_PG_APPLICATION INFORMATION LIBRARY AIL
+ @{
-<h1 class="pg">Introduction</h1>
+ <h1 class="pg">Introduction</h1>
-<h2 class="pg">Purpose of this document</h2>
- The purpose of this document is to describe how applications can use Application information library APIs to store/retrive the application's informations. This document gives programming guidelines to the application engineers.
+ <h2 class="pg">Purpose of this document</h2>
+ The purpose of this document is to describe how applications can use Application information library APIs to store/retrive the application's informations. This document gives programming guidelines to the application engineers.
-<h2 class="pg">Scope</h2>
-The scope of this document is limited to AIL API usage.
+ <h2 class="pg">Scope</h2>
+ The scope of this document is limited to AIL API usage.
-<h1 class="pg">Architecture</h1>
+ <h1 class="pg">Architecture</h1>
-<h2 class="pg">Architecture overview</h2>
-Application information library manages the application information such as application name, type, icon path, exe path etc.
+ <h2 class="pg">Architecture overview</h2>
+ Application information library manages the application information such as application name, type, icon path, exe path etc.
-@image html SLP_ail_logical_view.png
+ @image html SLP_ail_logical_view.png
-<h2 class="pg">SLP Features</h2>
-- The Application information library provides installed applications informations.
-- The Application information library exposes the APIs to filter the applcation based on certain fields.
-- The Application information library uses DB to store the informations of the application.
-- The Application information library can process the desktop file to store/retrive the informations.
+ <h2 class="pg">SLP Features</h2>
+ - The Application information library provides installed applications informations.
+ - The Application information library exposes the APIs to filter the applcation based on certain fields.
+ - The Application information library uses DB to store the informations of the application.
+ - The Application information library can process the desktop file to store/retrive the informations.
-<h1 class="pg">Application information library properties</h1>
+ <h1 class="pg">Application information library properties</h1>
-<h2 class="pg">AIL Functionality</h2>
-There are three types of API's provided by AIL
-- ail_appinfo_xxx
- - Get the informations of the given package.
-- ail_filter_xxx
- - Get the Application informations matched to filter condition.
-- ail_desktop_xxx
- - add, update or remove package informations in DB.
+ <h2 class="pg">AIL Functionality</h2>
+ There are three types of API's provided by AIL
+ - ail_appinfo_xxx
+ - Get the informations of the given package.
+ - ail_filter_xxx
+ - Get the Application informations matched to filter condition.
+ - ail_desktop_xxx
+ - add, update or remove package informations in DB.
-<h2 class="pg">Software Components</h2>
-- Query Requester
- - It provides the interface to the DB. It is responsible for forming the query and excute the query in db.
-- Desktop file Reader/parser
- - It can read the application's desktop file from the file system (/opt/share/application/).
-- Filter
- - It can filter the query based on the given condition and it returns the filtered output to the application.
-- Get App info
- - It can get the information of the application using appid.
+ <h2 class="pg">Software Components</h2>
+ - Query Requester
+ - It provides the interface to the DB. It is responsible for forming the query and excute the query in db.
+ - Desktop file Reader/parser
+ - It can read the application's desktop file from the file system (/opt/share/application/).
+ - Filter
+ - It can filter the query based on the given condition and it returns the filtered output to the application.
+ - Get App info
+ - It can get the information of the application using appid.
-<h1 class="pg"> Software module Details </h2>
+ <h1 class="pg"> Software module Details </h2>
-<h2 class="pg"> Query Requester </h2>
- - Query Requester module is provides the interface to sql DB in AIL.
- - It is responsible for creating connection to the DB, form the sql query and execute the query in DB.
- - It uses the libsql API to access the DB. (Eg) db_xx() API.
+ <h2 class="pg"> Query Requester </h2>
+ - Query Requester module is provides the interface to sql DB in AIL.
+ - It is responsible for creating connection to the DB, form the sql query and execute the query in DB.
+ - It uses the libsql API to access the DB. (Eg) db_xx() API.
-@code
+ @code
-@brief string type properties
+ @brief string type properties
#define AIL_PROP_PACKAGE_STR "AIL_PROP_PACKAGE_STR"
#define AIL_PROP_EXEC_STR "AIL_PROP_EXEC_STR"
<h2 class="pg">Desktop file Reader/parser</h2>
- - This module provides set of APIs to add update delete application's desktop files contents in DB.
+- This module provides set of APIs to add update delete application's desktop files contents in DB.
- It is responsible for validate the desktop file contents are in standard format.
- - The major functionality of this module is add, update and delete desktop file contents in DB Eg.(ail_desktop_xxx())
+- The major functionality of this module is add, update and delete desktop file contents in DB Eg.(ail_desktop_xxx())
<h3 class="pg"> Desktop file specification </h3>
- - http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#introduction
- - Desktop entry files should have the .desktop extension
- - Entries in the file are {key,value} pairs in the format: Key=Value
- - Standard Keys
- - Type, Version, Name, NoDisplay, Icon, Hidden, Exec, Path, MimeType, Categories, URL, etc
- - The Exec key must contain a command line. A command line consists of an executable program optionally followed by one or more arguments.
- - The executable program can either be specified with its full path or with the name of the executable only.
- - If no full path is provided the executable is looked up in the $PATH environment variable used by the desktop environment.
- - The name or path of the executable program may not contain the equal sign ("="). Arguments are separated by a space.
-
-@image html SLP_AIL_desktop.png
-
-<h2 class="pg"> Adding desktop file to DB </h2>
-@image html SLP_AIL_add.png
-<h2 class="pg" > Sample code </h2>
-@code
+ - http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#introduction
+ - Desktop entry files should have the .desktop extension
+ - Entries in the file are {key,value} pairs in the format: Key=Value
+ - Standard Keys
+ - Type, Version, Name, NoDisplay, Icon, Hidden, Exec, Path, MimeType, Categories, URL, etc
+ - The Exec key must contain a command line. A command line consists of an executable program optionally followed by one or more arguments.
+ - The executable program can either be specified with its full path or with the name of the executable only.
+ - If no full path is provided the executable is looked up in the $PATH environment variable used by the desktop environment.
+ - The name or path of the executable program may not contain the equal sign ("="). Arguments are separated by a space.
+
+ @image html SLP_AIL_desktop.png
+
+ <h2 class="pg"> Adding desktop file to DB </h2>
+ @image html SLP_AIL_add.png
+ <h2 class="pg" > Sample code </h2>
+ @code
static ail_error_e _add_desktop(const char *package)
{
- ail_error_e ret;
+ ail_error_e ret;
- if (!package) {
- return AIL_ERROR_FAIL;
- }
+ if (!package) {
+ return AIL_ERROR_FAIL;
+ }
- ret = ail_desktop_add(package);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
+ ret = ail_desktop_add(package);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
- return AIL_ERROR_OK;
+ return AIL_ERROR_OK;
}
static ail_error_e _remove_desktop(const char *package)
{
- ail_error_e ret;
+ ail_error_e ret;
- if (!package) {
- return AIL_ERROR_FAIL;
- }
+ if (!package) {
+ return AIL_ERROR_FAIL;
+ }
- ret = ail_desktop_remove(package);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
+ ret = ail_desktop_remove(package);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
- return AIL_ERROR_OK;
+ return AIL_ERROR_OK;
}
@endcode
<h2 class="pg">Filter</h2>
This module provides set of APIs to get the information from the DB based on the given matched condtion.
It is reponsbile for giving the filtered output to the applications. Eg.(ail_filter_xxx()) These following are some of the filtering condition.
- - Filter integer type only
- - Filter string type only
- - Filter bool type only
+- Filter integer type only
+- Filter string type only
+- Filter bool type only
<h3 class="pg" > Filter sample code </h3>
-@code
+ @code
ail_cb_ret_e appinfo_func(const ail_appinfo_h appinfo, void *user_data)
{
- int *i = (int *)user_data;
- char *package;
+ int *i = (int *)user_data;
+ char *package;
- ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
- printf("i=%d %s\n", (*i)++, package);
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+ printf("i=%d %s\n", (*i)++, package);
- if (*i > 30)
- return AIL_CB_RET_CANCEL;
+ if (*i > 30)
+ return AIL_CB_RET_CANCEL;
- return AIL_CB_RET_CONTINUE;
+ return AIL_CB_RET_CONTINUE;
}
int list_packages()
{
- ail_filter_h filter;
- ail_error_e ret;
- int i=0;
+ ail_filter_h filter;
+ ail_error_e ret;
+ int i=0;
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
- ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
+ ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
- ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
+ ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
+ if (ret != AIL_ERROR_OK) {
+ return -1;
+ }
- printf("List packages which are removable and 'Application' typed\n");
- ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+ printf("List packages which are removable and 'Application' typed\n");
+ ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
- ail_filter_destroy(filter);
+ ail_filter_destroy(filter);
- return 0;
+ return 0;
}
@endcode
<h2 class="pg">Get Application info</h2>
- This module provides set of APIs to get informations of the installed packages.
- - This module internally uses the query Requester module to get the information of the requested packages in DB. Eg.(ail_appinfo_xxx())
-@image html SLP_AIL_get.png
+- This module internally uses the query Requester module to get the information of the requested packages in DB. Eg.(ail_appinfo_xxx())
+ @image html SLP_AIL_get.png
-@code
+ @code
static ail_error_e _get_name(const char *package)
{
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str;
-
- ret = ail_package_get_appinfo(package, &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", package, property, str);
-
- ret = ail_package_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str;
+
+ ret = ail_package_get_appinfo(package, &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", package, property, str);
+
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
}
@endcode
- @}
+@}
**/
+
+#endif /* __SLP_AIL_PG_H__ */
*
*/
-
-
-
#ifndef __AIL_H__
#define __AIL_H__
#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_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" {
#endif /* __cplusplus */
-
-
/**
* @open
* @ingroup APPLICATION_FRAMEWORK
#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"
+#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
typedef struct ail_appinfo *ail_appinfo_h;
/**
- * @brief return values
+ * @brief return values
*/
typedef enum {
- AIL_ERROR_OK = 0, /**< General success */
- AIL_ERROR_FAIL = -1, /**< General error */
- AIL_ERROR_DB_FAILED = -2, /**< Database error */
- AIL_ERROR_OUT_OF_MEMORY = -3, /**< Out of memory */
- AIL_ERROR_INVALID_PARAMETER = -4, /**< Invalid parameter */
- AIL_ERROR_NO_DATA = -5, /**< Success, but no data */
+ AIL_ERROR_OK = 0, /**< General success */
+ AIL_ERROR_FAIL = -1, /**< General error */
+ AIL_ERROR_DB_FAILED = -2, /**< Database error */
+ AIL_ERROR_OUT_OF_MEMORY = -3, /**< Out of memory */
+ AIL_ERROR_INVALID_PARAMETER = -4, /**< Invalid parameter */
+ AIL_ERROR_NO_DATA = -5, /**< Success, but no data */
} ail_error_e;
/**
* External Apps.
*
* @code
-int count_apps()
-{
- ail_filter_h filter;
- ail_error_e ret;
- int n;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_count_appinfo(filter, &n);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
- ret = ail_filter_destroy(filter);
-
- printf("N of apps not to be displayed and supporting 'audo/wav' mime type = %d\n", n);
-
- return n;
-}
+ * int count_apps()
+ * {
+ * ail_filter_h filter;
+ * ail_error_e ret;
+ * int n;
+ *
+ * ret = ail_filter_new(&filter);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_count_appinfo(filter, &n);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_destroy(filter);
+ * printf("N of apps not to be displayed and supporting 'audo/wav' mime type = %d\n", n);
+ *
+ * return n;
+ * }
* @endcode
*/
ail_error_e ail_filter_new(ail_filter_h *filter);
-
-
/**
* @fn ail_error_e ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const int value)
*
* @par Sync (or) Async : Synchronous API
*
* @param[in] filter a filter handle which can be create with ail_filter_new()
- * @param[in] property a property type of integer
- * @param[in] value the value to filter by
+ * @param[in] property a property type of integer
+ * @param[in] value the value to filter by
*
* @return 0 if success, negative value(<0) if fail\n
* @retval AIL_ERROR_OK success
* External Apps.
*
* @code
-int count_apps()
-{
- ail_filter_h filter;
- ail_error_e ret;
- int n;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_int(filter, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, 480);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_count_appinfo(filter, &n);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- printf("N of apps = %d\n", n);
-
- return n;
-}
+ * int count_apps()
+ * {
+ * ail_filter_h filter;
+ * ail_error_e ret;
+ * int n;
+ *
+ * ret = ail_filter_new(&filter);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_int(filter, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, 480);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_count_appinfo(filter, &n);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * printf("N of apps = %d\n", n);
+ *
+ * return n;
+ * }
* @endcode
*/
ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const int value);
* External Apps.
*
* @code
-int count_apps()
-{
- ail_filter_h filter;
- ail_error_e ret;
- int n;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_count_appinfo(filter, &n);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- fprintf(stderr, "N of apps = %d\n", n);
-
- return n;
-}
+ * int count_apps()
+ * {
+ * ail_filter_h filter;
+ * ail_error_e ret;
+ * int n;
+ *
+ * ret = ail_filter_new(&filter);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_count_appinfo(filter, &n);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * fprintf(stderr, "N of apps = %d\n", n);
+ *
+ * return n;
+ * }
* @endcode
*/
ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, bool value);
-
-
/**
* @fn ail_error_e ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value)
*
* @param[in] value the value to filter by
*
* @return 0 if success, negative value(<0) if fail\n
- * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_OK success
* @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
* @retval AIL_ERROR_OUT_OF_MEMORY out of memory
*
* @par Prospective Clients:
* External Apps.
*
- * @code
-int count_apps()
-{
- ail_filter_h filter;
- ail_error_e ret;
- int n;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_str(filter, AIL_PROP_PACKAGE_STR, "com.samsung.memo");
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_count_appinfo(filter, &n);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- fprintf(stderr, "N of apps = %d\n", n);
-
- return n;
-}
+ * @codea
+ * int count_apps()
+ * {
+ * ail_filter_h filter;
+ * ail_error_e ret;
+ * int n;
+ *
+ * ret = ail_filter_new(&filter);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_str(filter, AIL_PROP_PACKAGE_STR, "com.samsung.memo");
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_count_appinfo(filter, &n);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * fprintf(stderr, "N of apps = %d\n", n);
+ *
+ * return n;
+ * }
* @endcode
*/
ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value);
-
/**
* @fn ail_error_e ail_filter_destroy(ail_filter_h filter)
*
* @param[in] filter filter handle
*
* @return 0 if success, negative value(<0) if fail\n
- * @retval AIL_ERROR_OK success
- * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
*
* @post If the filter is no longer used, it should be freed with ail_filter_destroy()
*
* External Apps.
*
* @code
-int count_apps()
-{
- ail_filter_h filter;
- ail_error_e ret;
- int n;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_count_appinfo(filter, &n);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- printf("N of removable apps = %d\n", n);
-
- ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_count_appinfo(filter, &n);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- printf("N of apps removable and supporting 'audo/wav' mime type = %d\n", n);
-
- ret = ail_filter_destroy(filter);
-
- return n;
-}
+ * int count_apps()
+ * {
+ * ail_filter_h filter;
+ * ail_error_e ret;
+ * int n;
+ *
+ * ret = ail_filter_new(&filter);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_count_appinfo(filter, &n);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * printf("N of removable apps = %d\n", n);
+ *
+ * ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, "audio/wav");
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_count_appinfo(filter, &n);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * printf("N of apps removable and supporting 'audo/wav' mime type = %d\n", n);
+ *
+ * ail_filter_destroy(filter);
+ *
+ * return n;
+ * }
* @endcode
*/
ail_error_e ail_filter_destroy(ail_filter_h filter);
-
-
/**
* @brief return value type of ail_list_appinfo_cb
*/
* @param[in] user_data user data passed to ail_filtet_list_appinfo_foreach()
*
* @return 0 if success, negative value(<0) if fail\n
- * @retval AIL_CB_RET_CONTINUE return if you continue iteration
- * @retval AIL_CB_RET_CANCEL return if you cancel iteration
+ * @retval AIL_CB_RET_CONTINUE return if you continue iteration
+ * @retval AIL_CB_RET_CANCEL return if you cancel iteration
*
* @see ail_filter_list_appinfo_foreach()
*/
-typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void *user_data,uid_t uid);
+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)
* @par Sync (or) Async : Synchronous API
*
* @param[in] filter a filter handle
- * @param[in] func the function to call with each app's appinfo
+ * @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
+ * @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_DB_FAILED database error
- * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
*
* @see ail_list_appinfo_cb
* @see ail_filter_add_bool()
* External Apps.
*
* @code
-
-ail_cb_ret_e appinfo_func(const ail_appinfo_h appinfo, void *user_data)
-{
- int *i = (int *)user_data;
- char *appid;
-
- ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &appid);
- printf("i=%d %s\n", (*i)++, appid);
-
- if (*i > 30)
- return AIL_CB_RET_CANCEL;
-
- return AIL_CB_RET_CONTINUE;
-}
-
-int list_apps()
-{
- ail_filter_h filter;
- ail_error_e ret;
- int i=0;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- printf("List apps which are removable and 'Application' typed\n");
- ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
-
- ail_filter_destroy(filter);
-
- return 0;
-}
+ * ail_cb_ret_e appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+ * {
+ * int *i = (int *)user_data;
+ * char *appid;
+ *
+ * ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &appid);
+ * printf("i=%d %s\n", (*i)++, appid);
+ *
+ * if (*i > 30)
+ * return AIL_CB_RET_CANCEL;
+ *
+ * return AIL_CB_RET_CONTINUE;
+ * }
+ *
+ * int list_apps()
+ * {
+ * ail_filter_h filter;
+ * ail_error_e ret;
+ * int i = 0;
+ *
+ * ret = ail_filter_new(&filter);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * printf("List apps which are removable and 'Application' typed\n");
+ * ail_filter_list_appinfo_foreach(filter, appinfo_func, (void *)&i);
+ * ail_filter_destroy(filter);
+ *
+ * return 0;
+ * }
* @endcode
*/
ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter,
- ail_list_appinfo_cb appinfo_func,
- void *user_data);
+ 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);
+ 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, uid_t uid)
* @fn ail_error_e ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count)
* @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
+ * @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
- * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
- * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ * @retval AIL_ERROR_OUT_OF_MEMORY out of memory
*
* @pre None
* @post None
* External Apps.
*
* @code
-int count_apps()
-{
- ail_filter_h filter;
- ail_error_e ret;
- int n;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, true);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_count_appinfo(filter, &n);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- printf("N of app not to be displayed = %d", n);
-
- ret = ail_filter_count_appinfo(NULL, &n);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- printf("N of all app = %d\n", n);
-
- return n;
-}
+ * int count_apps()
+ * {
+ * ail_filter_h filter;
+ * ail_error_e ret;
+ * int n;
+ *
+ * ret = ail_filter_new(&filter);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, true);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * ret = ail_filter_count_appinfo(filter, &n);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * printf("N of app not to be displayed = %d", n);
+ *
+ * ret = ail_filter_count_appinfo(NULL, &n);
+ * if (ret != AIL_ERROR_OK)
+ * return -1;
+ *
+ * printf("N of all app = %d\n", n);
+ *
+ * return n;
+ * }
* @endcode
*/
ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *count);
/**
* @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.
- If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
-
+ * @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.
+ * If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
* @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[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
- * @retval AIL_ERROR_OK success
- * @retval AIL_ERROR_FAIL internal error
- * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_FAIL internal error
+ * @retval AIL_ERROR_DB_FAILED database error
* @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
- * @retval AIL_ERROR_NO_DATA no data. cannot find the package.
+ * @retval AIL_ERROR_NO_DATA no data. cannot find the package.
*
* @pre declare a handle before calling this function. The handle is used as a second argument of this API.
* @post destroy the handle with the function of ail_package_destroy_appinfo after using it all.
* External Apps.
*
* @code
-static ail_error_e _get_name(const char *package)
-{
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str;
-
- ret = ail_package_get_appinfo(package, &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", package, property, str);
-
- ret = ail_package_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
-}
+ * static ail_error_e _get_name(const char *package)
+ * {
+ * ail_appinfo_h handle;
+ * ail_error_e ret;
+ * char *str;
+ *
+ * ret = ail_package_get_appinfo(package, &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", package, property, str);
+ *
+ * ret = ail_package_destroy_appinfo(handle);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @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.
- If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
-
+ * 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.
+ * If you want to read a value from the retrieving data, you have to use the functions of ail_appinfo_get_xxx.
+ *
* @par Sync (or) Async : Synchronous API.
*
* @param[in] appid appid what you want to know about.
* @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
- * @retval AIL_ERROR_OK success
- * @retval AIL_ERROR_FAIL internal error
- * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_FAIL internal error
+ * @retval AIL_ERROR_DB_FAILED database error
* @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
- * @retval AIL_ERROR_NO_DATA no data. cannot find the app.
+ * @retval AIL_ERROR_NO_DATA no data. cannot find the app.
*
* @pre declare a handle before calling this function. The handle is used as a second argument of this API.
* @post destroy the handle with the function of ail_get_appinfo after using it all.
* 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;
- }
-
- return AIL_ERROR_OK;
-}
+ * 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;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @endcode
*/
ail_error_e ail_get_appinfo(const char *appid, ail_appinfo_h *handle);
/**
* @fn ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value)
*
- * @brief get a boolean value 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.
+ * @brief get a boolean value 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.
*
* @par Sync (or) Async : Synchronous API.
*
* @param[out] value a out-parameter value that is mapped with the property.
*
* @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
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
*
* @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
* @post destroy the handle with the function of ail_destroy_appinfo after using it all.
* External Apps.
*
* @code
-static ail_error_e _get_nodisplay(const char *appid)
-{
- ail_appinfo_h handle;
- ail_error_e ret;
- bool value;
-
- ret = ail_get_appinfo(appid, &handle);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- ret = ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &value);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
- fprintf(stderr, "appid[%s] : %d\n", appid, value);
-
- ret = ail_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
-}
+ * static ail_error_e _get_nodisplay(const char *appid)
+ * {
+ * ail_appinfo_h handle;
+ * ail_error_e ret;
+ * bool value;
+ *
+ * ret = ail_get_appinfo(appid, &handle);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * ret = ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &value);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * fprintf(stderr, "appid[%s] : %d\n", appid, value);
+ *
+ * ret = ail_destroy_appinfo(handle);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @endcode
*/
ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *property, bool *value);
-
-
/**
* @fn ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property, int *value)
*
- * @brief get a integer value 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.
+ * @brief get a integer value 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.
*
* @par Sync (or) Async : Synchronous API.
*
* @param[out] value a out-parameter value that is mapped with the property.
*
* @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_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
* @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
*
* @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
* External Apps.
*
* @code
-static ail_error_e _get_x_slp_baselayoutwidth(const char *appid)
-{
- ail_appinfo_h handle;
- ail_error_e ret;
- int value;
-
- ret = ail_get_appinfo(appid, &handle);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, &value);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
- fprintf(stderr, "Package[%s] : %d\n", appid, value);
-
- ret = ail_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
-}
+ * static ail_error_e _get_x_slp_baselayoutwidth(const char *appid)
+ * {
+ * ail_appinfo_h handle;
+ * ail_error_e ret;
+ * int value;
+ *
+ * ret = ail_get_appinfo(appid, &handle);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, &value);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * fprintf(stderr, "Package[%s] : %d\n", appid, value);
+ *
+ * ret = ail_destroy_appinfo(handle);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @endcode
*/
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, 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.
+ * @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.
*
* @par Sync (or) Async : Synchronous API.
*
* @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
- * @retval AIL_ERROR_OK success
- * @retval AIL_ERROR_DB_FAILED database error
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_DB_FAILED database error
* @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
*
* @pre define a handle using ail_get_appinfo. The handle is used as a first argument of this API.
* External Apps.
*
* @code
-static ail_error_e _get_nodisplay(const char *appid)
-{
- ail_appinfo_h handle;
- ail_error_e ret;
- char* value;
-
- 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, &value);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
- fprintf(stderr, "Package[%s] : %d\n", appid, value);
-
- ret = ail_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
-}
+ * static ail_error_e _get_nodisplay(const char *appid)
+ * {
+ * ail_appinfo_h handle;
+ * ail_error_e ret;
+ * char* value;
+ *
+ * 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, &value);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * fprintf(stderr, "Package[%s] : %d\n", appid, value);
+ *
+ * ret = ail_destroy_appinfo(handle);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @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);
-
/**
* @fn ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle)
*
* @param[in] handle destroy all resources related to the handle.
*
* @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_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.
* External Apps.
*
* @code
-static ail_error_e _get_name(const char *package)
-{
- ail_appinfo_h handle;
- ail_error_e ret;
- char *str;
-
- ret = ail_package_get_appinfo(package, &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", package, property, str);
-
- ret = ail_package_destroy_appinfo(handle);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
-}
+ * static ail_error_e _get_name(const char *package)
+ * {
+ * ail_appinfo_h handle;
+ * ail_error_e ret;
+ * char *str;
+ *
+ * ret = ail_package_get_appinfo(package, &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", package, property, str);
+ *
+ * ret = ail_package_destroy_appinfo(handle);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @endcode
*/
ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle) __attribute__((deprecated));
-
/**
* @fn ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle)
*
* @param[in] handle destroy all resources related to the handle.
*
* @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_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.
* 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;
- }
-
- return AIL_ERROR_OK;
-}
+ * 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;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @endcode
*/
ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle);
* @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_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.
* 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;
-}
+ * 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.
- If there is a DB, this function adds information for the app into the DB.
- And a notification is published to the applications who want to know about changing DB.
+ * 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 published to the applications who want to know about changing DB.
*
* @par Sync (or) Async : Synchronous API.
*
* @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
+ * @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.
* External Apps.
*
* @code
-static ail_error_e _add_desktop(const char *appid)
-{
- ail_error_e ret;
-
- if (!appid) {
- return AIL_ERROR_FAIL;
- }
-
- ret = ail_desktop_add(appid);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
-}
+ * static ail_error_e _add_desktop(const char *appid)
+ * {
+ * ail_error_e ret;
+ *
+ * if (!appid)
+ * return AIL_ERROR_FAIL;
+ *
+ * ret = ail_desktop_add(appid);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @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.
+ * 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.
*
* @par Sync (or) Async : Synchronous API.
*
* @param[in] appid
- * @param[in] uid ID of the owner of the application
+ * @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
+ * @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 update a app information in the Application Information Database.
* External Apps.
*
* @code
-static ail_error_e _update_desktop(const char *appid)
-{
- ail_error_e ret;
-
- if (!appid) {
- return AIL_ERROR_FAIL;
- }
-
- ret = ail_desktop_update(appid);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
-}
+ * static ail_error_e _update_desktop(const char *appid)
+ * {
+ * ail_error_e ret;
+ *
+ * if (!appid)
+ * return AIL_ERROR_FAIL;
+ *
+ * ret = ail_desktop_update(appid);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @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.
+ * And a notification is published to the applications who want to know about changing DB.
*
* @par Sync (or) Async : Synchronous API.
*
* @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
+ * @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.
* External Apps.
*
* @code
-static ail_error_e _remove_desktop(const char *appid)
-{
- ail_error_e ret;
-
- if (!appid) {
- return AIL_ERROR_FAIL;
- }
-
- ret = ail_desktop_remove(appid);
- if (ret != AIL_ERROR_OK) {
- return AIL_ERROR_FAIL;
- }
-
- return AIL_ERROR_OK;
-}
+ * static ail_error_e _remove_desktop(const char *appid)
+ * {
+ * ail_error_e ret;
+ *
+ * if (!appid)
+ * return AIL_ERROR_FAIL;
+ *
+ * ret = ail_desktop_remove(appid);
+ * if (ret != AIL_ERROR_OK)
+ * return AIL_ERROR_FAIL;
+ *
+ * return AIL_ERROR_OK;
+ * }
* @endcode
*/
ail_error_e ail_desktop_remove(const char *appid);
* @par Sync (or) Async : Synchronous API.
*
* @param[in] pkgid
- * @param[in] uid ID of the owner of the application
+ * @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
+ * @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.
* 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;
-}
+ * 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);
* @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.
+ * 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] 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
+ * @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.
* 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;
-}
+ * 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.
+ * 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
+ * @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
+ * @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.
* 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;
-}
+ * 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);
/** @} */
-
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __AIL_H__ */
-// End of a file
*
*/
-
-
-
+#define _GNU_SOURCE
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <db-util.h>
#define QUERY_CREATE_VIEW_LOCAL "CREATE temp VIEW localname as select distinct * from (select * from main.localname m union select * from Global.localname g)"
-#define SET_SMACK_LABEL(x,uid) \
+#define SET_SMACK_LABEL(x, uid) \
do { \
if (smack_setlabel((x), (((uid) == GLOBAL_USER) ? "*" : "User"), SMACK_LABEL_ACCESS)) \
_E("failed chsmack -a \"User/*\" %s", x); \
static __thread struct {
sqlite3 *dbUserro;
- sqlite3 *dbGlobalro;
- sqlite3 *dbUserrw;
- sqlite3 *dbGlobalrw;
+ sqlite3 *dbGlobalro;
+ sqlite3 *dbUserrw;
+ sqlite3 *dbGlobalrw;
} db_info = {
.dbUserro = NULL,
.dbGlobalro = NULL,
static int ail_db_change_perm(const char *db_file, uid_t uid)
{
- char buf[BUFSIZE];
char journal_file[BUFSIZE];
char *files[3];
int ret;
for (i = 0; files[i]; i++) {
/* Compare git_t type and not group name */
ret = chown(files[i], uid, userinfo->pw_gid);
- SET_SMACK_LABEL(files[i],uid);
+ SET_SMACK_LABEL(files[i], uid);
if (ret == -1) {
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", db_file, uid, userinfo->pw_gid, buf);
+ _E("FAIL : chown %s %d.%d, because %d", db_file, uid, userinfo->pw_gid, errno);
free(pwd_buf);
return AIL_ERROR_FAIL;
}
ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (ret == -1) {
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chmod %s 0664, because %s", db_file, buf);
+ _E("FAIL : chmod %s 0664, because %d", db_file, errno);
free(pwd_buf);
return AIL_ERROR_FAIL;
}
char *result = NULL;
struct group grpbuf;
struct group *grpinfo = NULL;
- char *dir = NULL;
struct passwd pwd;
struct passwd *userinfo = NULL;
int buflen;
return NULL;
}
- asprintf(&result, "%s/.applications/icons/", userinfo->pw_dir);
+ if (asprintf(&result, "%s/.applications/icons/", userinfo->pw_dir) == -1)
+ _E("out of memory: asprintf() is failed.");
+
free(pwd_buf);
} else {
result = strdup(tzplatform_mkpath(TZ_SYS_RW_ICONS, "/"));
ret = chown(result, uid, grpinfo ? grpinfo->gr_gid : 0);
SET_SMACK_LABEL(result, uid);
if (ret == -1) {
- char buf[BUFSIZE];
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", result, uid,
- grpinfo ? grpinfo->gr_gid : 0, buf);
+ _E("FAIL : chown %s %d.%d, because %d", result, uid,
+ grpinfo ? grpinfo->gr_gid : 0, errno);
}
}
char *app_path = ail_get_app_DB(uid);
char *result = NULL;
- asprintf(&result, "%s-journal", app_path);
+ if (asprintf(&result, "%s-journal", app_path) == -1)
+ _E("out of memory: asprintf() is failed.");
+
free(app_path);
return result;
return NULL;
}
- asprintf(&result, "%s/.applications/dbspace/.app_info.db", userinfo->pw_dir);
+ if (asprintf(&result, "%s/.applications/dbspace/.app_info.db", userinfo->pw_dir) == -1)
+ _E("out of memory: asprintf() is failed.");
+
free(pwd_buf);
} else {
result = strdup(APP_INFO_DB_FILE);
_E("FAIL : to create directory %s %d", temp, errno);
} else if (getuid() == OWNER_ROOT) {
ret = chown(temp, uid, grpinfo ? grpinfo->gr_gid : 0);
- SET_SMACK_LABEL(temp,uid);
+ SET_SMACK_LABEL(temp, uid);
if (ret == -1) {
- char buf[BUFSIZE];
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", temp, uid,
- grpinfo ? grpinfo->gr_gid : 0, buf);
+ _E("FAIL : chown %s %d.%d, because %d", temp, uid,
+ grpinfo ? grpinfo->gr_gid : 0, errno);
}
}
char *result = NULL;
struct group grpbuf;
struct group *grpinfo = NULL;
- char *dir = NULL;
struct passwd pwd;
struct passwd *userinfo = NULL;
int buflen;
return NULL;
}
- asprintf(&result, "%s/.applications/desktop/", userinfo->pw_dir);
+ if (asprintf(&result, "%s/.applications/desktop/", userinfo->pw_dir) == -1)
+ _E("out of memory: asprintf() is failed.");
+
free(pwd_buf);
} else {
result = strdup(tzplatform_mkpath(TZ_SYS_RW_DESKTOP_APP, "/"));
_E("FAIL : to create directory %s %d", result, errno);
} else if (getuid() == OWNER_ROOT) {
ret = chown(result, uid, grpinfo ? grpinfo->gr_gid : 0);
- SET_SMACK_LABEL(result,uid);
+ SET_SMACK_LABEL(result, uid);
if (ret == -1) {
- char buf[BUFSIZE];
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", result, uid,
- grpinfo ? grpinfo->gr_gid : 0, buf);
+ _E("FAIL : chown %s %d.%d, because %d", result, uid,
+ grpinfo ? grpinfo->gr_gid : 0, errno);
}
}
ail_error_e db_open(db_open_mode mode, uid_t uid)
{
int ret;
- int changed = 0;
int i;
char *db;
char *global_db;
}
if (access(db, F_OK)) {
- if (AIL_ERROR_OK == db_util_open_with_options(db, &dbInit, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL))
- {
+ if (AIL_ERROR_OK == db_util_open_with_options(db,
+ &dbInit, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL)) {
for (i = 0; tbls[i] != NULL; i++) {
ret = do_db_exec(tbls[i], dbInit);
if (ret != AIL_ERROR_OK)
goto catch;
}
- if(getuid() == OWNER_ROOT && AIL_ERROR_OK != ail_db_change_perm(db, uid)) {
+ if (getuid() == OWNER_ROOT && AIL_ERROR_OK != ail_db_change_perm(db, uid))
_E("Failed to change permission\n");
- }
} else {
dbInit = NULL;
_E("Failed to create table %s\n", db);
tryvm_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
dbInit = NULL;
}
- if(mode & DB_OPEN_RO) {
- if(uid != GLOBAL_USER) {
+ if (mode & DB_OPEN_RO) {
+ if (uid != GLOBAL_USER) {
if (!db_info.dbUserro) {
db_util_open_with_options(db, &db_info.dbUserro, SQLITE_OPEN_READONLY, NULL);
char query_attach[AIL_SQL_QUERY_MAX_LEN];
return AIL_ERROR_OK;
}
-ail_error_e db_bind_text(sqlite3_stmt *stmt, int idx, char* value)
+ail_error_e db_bind_text(sqlite3_stmt *stmt, int idx, const char* value)
{
int ret;
ret = sqlite3_step(stmt);
switch (ret) {
- case SQLITE_DONE:
- return AIL_ERROR_NO_DATA;
- case SQLITE_ROW:
- return AIL_ERROR_OK;
+ case SQLITE_DONE:
+ return AIL_ERROR_NO_DATA;
+ case SQLITE_ROW:
+ return AIL_ERROR_OK;
}
retv_with_dbmsg_if(1, AIL_ERROR_DB_FAILED);
retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
out_val = sqlite3_column_int(stmt, index);
- *value = (out_val == 1)? true:false;
+ *value = (out_val == 1) ? true : false;
return AIL_ERROR_OK;
}
ret = sqlite3_exec(fileSQL, query, NULL, NULL, &errmsg);
if (ret != SQLITE_OK) {
_E("Cannot execute this query - %s. because %s",
- query, errmsg? errmsg:"uncatched error");
- if(errmsg)
+ query, errmsg ? errmsg : "uncatched error");
+ if (errmsg)
sqlite3_free(errmsg);
return AIL_ERROR_DB_FAILED;
}
{
int ret;
- if(db_info.dbUserro) {
+ if (db_info.dbUserro) {
ret = sqlite3_close(db_info.dbUserro);
retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
-
db_info.dbUserro = NULL;
}
- if(db_info.dbGlobalrw) {
+
+ if (db_info.dbGlobalrw) {
ret = sqlite3_close(db_info.dbGlobalrw);
retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
-
db_info.dbGlobalrw = NULL;
}
- if(db_info.dbUserrw) {
+
+ if (db_info.dbUserrw) {
ret = sqlite3_close(db_info.dbUserrw);
retv_with_dbmsg_if(ret != SQLITE_OK, AIL_ERROR_DB_FAILED);
-
db_info.dbUserrw = NULL;
}
int db_exec_sqlite_query(char *query, sqlite_query_callback callback, void *data)
{
char *error_message = NULL;
- if(db_info.dbGlobalro) {
+ if (db_info.dbGlobalro) {
if (SQLITE_OK !=
sqlite3_exec(db_info.dbGlobalro, query, callback, data, &error_message)) {
_E("Don't execute query = %s error message = %s\n", query,
return -1;
}
}
- if(db_info.dbUserro) {
+ if (db_info.dbUserro) {
if (SQLITE_OK !=
sqlite3_exec(db_info.dbUserro, query, callback, data, &error_message)) {
_E("Don't execute query = %s error message = %s\n", query,
*
*/
-
-
-
#ifndef __AIL_DB_H__
#define __AIL_DB_H__
ail_error_e db_bind_bool(sqlite3_stmt *stmt, int idx, bool value);
ail_error_e db_bind_int(sqlite3_stmt *stmt, int idx, int value);
-ail_error_e db_bind_text(sqlite3_stmt *stmt, int idx, char* value);
+ail_error_e db_bind_text(sqlite3_stmt *stmt, int idx, const char *value);
ail_error_e db_step(sqlite3_stmt *stmt);
ail_error_e db_reset(sqlite3_stmt *stmt);
ail_error_e db_finalize(sqlite3_stmt *stmt);
-ail_error_e do_db_exec(const char *query,sqlite3 * fileSQL);
+ail_error_e do_db_exec(const char *query, sqlite3 *fileSQL);
ail_error_e db_exec_usr_rw(const char *query);
ail_error_e db_exec_usr_ro(const char *query);
+ail_error_e db_exec_glo_rw(const char *query);
ail_error_e db_close(void);
int db_exec_sqlite_query(char *query, sqlite_query_callback callback, void *data);
-#endif
-// End of file
+
+#endif /* __AIL_DB_H__ */
#include "ail_sql.h"
#include "ail.h"
#include "ail_vconf.h"
+#include "ail_convert.h"
#define BUFSIZE 4096
#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
#define SQL_INSERT_LOCALNAME_INIT_STR SQL_INSERT_LOCALNAME_STR"( ?, ?, ?) "
#define SQL_LOCALNAME_TRIPLET_STR ", ( ?, ?, ?)"
-#define SQL_LOCALNAME_TRIPLET_STR_LEN (sizeof(SQL_LOCALNAME_TRIPLET_STR)-1)
+#define SQL_LOCALNAME_TRIPLET_STR_LEN (sizeof(SQL_LOCALNAME_TRIPLET_STR) - 1)
typedef enum {
NOTI_ADD,
ail_error_e (*value_cb)(void *data, char *tag, char *value, uid_t uid);
};
-inline static char *_ltrim(char *str)
+static inline char *_ltrim(char *str)
{
- if (!str) return NULL;
+ if (!str)
+ return NULL;
- while (*str == ' ' || *str == '\t' || *str == '\n') str ++;
+ while (*str == ' ' || *str == '\t' || *str == '\n')
+ str++;
return str;
}
-
-
-inline static int _rtrim(char *str)
+static inline int _rtrim(char *str)
{
int len;
len = strlen(str);
- while (--len >= 0 && (str[len] == ' ' || str[len] == '\n' || str[len] == '\t')) str[len] = '\0';
+ while (--len >= 0 && (str[len] == ' ' || str[len] == '\n' || str[len] == '\t'))
+ str[len] = '\0';
return len;
}
GSList* localname;
} desktop_info_s;
-
-
static ail_error_e _read_exec(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
retv_if(!info->exec, AIL_ERROR_OUT_OF_MEMORY);
temp_exec = strdup(value);
- if(!temp_exec) {
+ if (!temp_exec) {
free(info->exec);
return AIL_ERROR_OUT_OF_MEMORY;
}
token_exe_path = strtok_r(temp_exec, argsdelimiter, &save_ptr);
info->x_slp_exe_path = strdup(token_exe_path);
- if(!info->x_slp_exe_path) {
+ if (!info->x_slp_exe_path) {
free(info->exec);
info->exec = NULL;
free(temp_exec);
return AIL_ERROR_OK;
}
-
-
static ail_error_e _read_name(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
if (tag && strlen(tag) > 0) {
struct name_item *item;
item = (struct name_item *)calloc(1, sizeof(struct name_item));
- retv_if (NULL == item, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(NULL == item, AIL_ERROR_OUT_OF_MEMORY);
SAFE_FREE_AND_STRDUP(tag, item->locale);
- if(NULL == item->locale) {
+ if (item->locale == NULL) {
_E("(NULL == item->locale) return\n");
free(item);
return AIL_ERROR_OUT_OF_MEMORY;
}
SAFE_FREE_AND_STRDUP(value, item->name);
- if(NULL == item->name) {
+ if (item->name == NULL) {
_E("(NULL == item->name) return\n");
free(item->locale);
free(item);
return AIL_ERROR_OK;
} else {
SAFE_FREE_AND_STRDUP(value, info->name);
- retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(!info->name, AIL_ERROR_OUT_OF_MEMORY);
return AIL_ERROR_OK;
}
}
-
-
static ail_error_e _read_type(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
SAFE_FREE_AND_STRDUP(value, info->type);
- retv_if (!info->type, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(!info->type, AIL_ERROR_OUT_OF_MEMORY);
return AIL_ERROR_OK;
}
-
-static char*
-_get_package_from_icon(char* icon)
+static char *_get_package_from_icon(char* icon)
{
- char* package;
- char* extension;
+ char *package;
+ char *extension;
retv_if(!icon, NULL);
package = strdup(icon);
retv_if(!package, NULL);
extension = rindex(package, '.');
- if (extension) {
+ if (extension)
*extension = '\0';
- } else {
+ else
_E("cannot extract from icon [%s] to package.", icon);
- }
return package;
}
-
static char*
_get_icon_with_path(char* icon, uid_t uid)
{
char* theme = NULL;
char* icon_with_path = NULL;
int len;
- char *app_path = NULL;
+ const char *app_path = NULL;
package = _get_package_from_icon(icon);
retv_if(!package, NULL);
-/* "db/setting/theme" is not exist */
-#if 0
- theme = ail_vconf_get_str("db/setting/theme");
- if (!theme) {
- theme = strdup("default");
- if(!theme) {
- free(package);
- return NULL;
- }
- }
-#else
+ /* "db/setting/theme" is not exist */
theme = strdup("default");
if (theme == NULL) {
_E("out of memory");
return NULL;
}
-#endif
-
len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
icon_with_path = malloc(len);
- if(icon_with_path == NULL) {
+ if (icon_with_path == NULL) {
_E("icon_with_path == NULL\n");
free(package);
free(theme);
}
memset(icon_with_path, 0, len);
+
if (uid != GLOBAL_USER)
- sqlite3_snprintf( len, icon_with_path, "%s%q", ail_get_icon_path(uid), icon);
+ sqlite3_snprintf(len, icon_with_path, "%s%q", ail_get_icon_path(uid), icon);
else
- sqlite3_snprintf( len, icon_with_path, "%s/%q/small/%q", ail_get_icon_path(GLOBAL_USER), theme, icon);
+ sqlite3_snprintf(len, icon_with_path, "%s/%q/small/%q", ail_get_icon_path(GLOBAL_USER), theme, icon);
- if (access (icon_with_path, F_OK)) {
+ if (access(icon_with_path, F_OK)) {
app_path = tzplatform_getenv(TZ_SYS_RW_APP);
if (app_path)
- sqlite3_snprintf( len, icon_with_path, "%s/%q/res/icons/%q/small/%q",app_path, package, theme, icon);
- if (access (icon_with_path, F_OK))
+ sqlite3_snprintf(len, icon_with_path, "%s/%q/res/icons/%q/small/%q", app_path, package, theme, icon);
+ if (access(icon_with_path, F_OK))
_E("Cannot find icon path");
}
free(theme);
}
}
-
static ail_error_e _read_icon(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
info->icon = _get_icon_with_path(value, uid);
- retv_if (!info->icon, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(!info->icon, AIL_ERROR_OUT_OF_MEMORY);
return AIL_ERROR_OK;
}
-
-
static ail_error_e _read_categories(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
SAFE_FREE_AND_STRDUP(value, info->categories);
- retv_if (!info->categories, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(!info->categories, AIL_ERROR_OUT_OF_MEMORY);
return AIL_ERROR_OK;
}
-
-
static ail_error_e _read_version(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
SAFE_FREE_AND_STRDUP(value, info->version);
- retv_if (!info->version, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(!info->version, AIL_ERROR_OUT_OF_MEMORY);
return AIL_ERROR_OK;
}
-
-
static ail_error_e _read_mimetype(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s *info = data;
size = getpagesize();
mimes_changed = calloc(1, size);
- if(mimes_changed == NULL) {
+ if (mimes_changed == NULL) {
_E("(mimes_changed == NULL) return\n");
free(mimes_origin);
return AIL_ERROR_OUT_OF_MEMORY;
char *tmp;
size *= 2;
tmp = realloc(mimes_changed, size);
- if(!tmp) {
+ if (!tmp) {
free(mimes_changed);
return AIL_ERROR_OUT_OF_MEMORY;
}
total_len += token_len;
token_unalias = strtok_r(NULL, ";", &save_ptr);
- if (token_unalias) {
+ if (token_unalias)
strncat(mimes_changed, ";", size-strlen(mimes_changed)-1);
- }
}
SAFE_FREE(info->mimetype);
return AIL_ERROR_OK;
}
-
-
static ail_error_e _read_nodisplay(void *data, char *tag, char *value, uid_t uid)
{
desktop_info_s* info = data;
},
};
-
-
-/* Utility functions */
-static int _count_all(uid_t uid)
-{
- ail_error_e ret;
- int count;
-
- if (uid != GLOBAL_USER)
- ret = ail_filter_count_usr_appinfo(NULL, &count, uid);
- else
- ret = ail_filter_count_appinfo(NULL, &count);
-
- if (ret != AIL_ERROR_OK) {
- _E("cannot count appinfo");
- count = -1;
- }
-
- return count;
-}
-
char *_pkgname_to_desktop(const char *package, uid_t uid)
{
char *desktop;
static inline int _bind_local_info(desktop_info_s* info, sqlite3_stmt * stmt)
{
- int ret = 0;
unsigned long i = 0;
struct name_item *item;
GSList* localname;
+
retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
retv_if(!info->localname, AIL_ERROR_INVALID_PARAMETER);
retv_if(!stmt, AIL_ERROR_INVALID_PARAMETER);
+
localname = info->localname;
while (localname) {
item = (struct name_item *) localname->data;
if (item && item->locale && item->name) {
- // Bind values for a triplet : package, locale, name
+ /* Bind values for a triplet : package, locale, name */
retv_if(db_bind_text(stmt, i+1, info->package) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
retv_if(db_bind_text(stmt, i+2, item->locale) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
retv_if(db_bind_text(stmt, i+3, item->name) != AIL_ERROR_OK, AIL_ERROR_DB_FAILED);
}
localname = g_slist_next(localname);
}
+
return AIL_ERROR_OK;
}
struct name_item *item;
GSList* localname;
retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
- if(info->localname) {
+ if (info->localname) {
localname = info->localname;
while (localname) {
item = (struct name_item *) localname->data;
if (item && item->locale && item->name)
- len ++;
+ len++;
localname = g_slist_next(localname);
}
}
ret = _bind_local_info(info, stmt);
if (ret < 0) {
- _E("Can't bind locale information to this query - %s. ",query);
+ _E("Can't bind locale information to this query - %s. ", query);
db_finalize(stmt);
break;
}
if (ret != AIL_ERROR_NO_DATA) {
/* Insert Request doesn't return any data.
* db_step should returns AIL_ERROR_NO_DATA in this case. */
- _E("Can't execute this query - %s. ",query);
+ _E("Can't execute this query - %s. ", query);
db_finalize(stmt);
break;
}
return len;
}
-
int __is_ail_initdb(void)
{
- if( getenv("AIL_INITDB") || getenv("INITDB") )
+ if (getenv("AIL_INITDB") || getenv("INITDB"))
return 1;
else
return 0;
return AIL_ERROR_OK;
}
-static ail_error_e _read_desktop_info(desktop_info_s* info,uid_t uid)
+static ail_error_e _read_desktop_info(desktop_info_s *info, uid_t uid)
{
char *line = NULL;
FILE *fp;
char *tmp, *field, *field_name, *tag, *value;
tmp = _ltrim(line);
- if(tmp == NULL) continue;
- if (*tmp == '#') continue;
- if (_rtrim(tmp) <= 0) continue;
+ if (tmp == NULL)
+ continue;
+ if (*tmp == '#')
+ continue;
+ if (_rtrim(tmp) <= 0)
+ continue;
len = strlen(line) + 1;
field = calloc(1, len);
tag = calloc(1, len);
value = calloc(1, len);
- if (!field || !field_name || !tag || !value) {
+ if (!field || !field_name || !tag || !value)
goto NEXT;
- }
sscanf(tmp, "%[^=]=%[^\n]", field, value);
_rtrim(field);
sscanf(field, "%[^[][%[^]]]", field_name, tag);
- if (!field_name || !strlen(field_name)){
+ if (!field_name || !strlen(field_name))
goto NEXT;
- }
- for (idx = 0; entry_parsers[idx].field; idx ++) {
+ for (idx = 0; entry_parsers[idx].field; idx++) {
if (!g_ascii_strcasecmp(entry_parsers[idx].field, field_name) && entry_parsers[idx].value_cb) {
- if (entry_parsers[idx].value_cb(info, tag, tmp,uid) != AIL_ERROR_OK) {
+ if (entry_parsers[idx].value_cb(info, tag, tmp, uid) != AIL_ERROR_OK)
_E("field - [%s] is wrong.", field_name);
- }
break;
}
}
return AIL_ERROR_FAIL;
snprintf(w, sizeof(w), filter, info->package);
- snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s",SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
+ snprintf(query, sizeof(query), "SELECT %s FROM %s WHERE %s", SQL_FLD_APP_INFO, SQL_TBL_APP_INFO, w);
do {
ret = db_open(DB_OPEN_RO, uid);
- if (ret < 0) break;
+ if (ret < 0)
+ break;
- if (uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER)
ret = db_prepare(query, &stmt);
- } else {
+ else
ret = db_prepare_globalro(query, &stmt);
- }
- if (ret < 0) break;
+ if (ret < 0)
+ break;
ret = db_step(stmt);
if (ret < 0) {
}
ret = db_finalize(stmt);
- if (ret < 0) break;
+ if (ret < 0)
+ break;
return AIL_ERROR_OK;
- } while(0);
+ } while (0);
return ret;
}
bool value)
{
ail_prop_bool_e prop;
- int val;
retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
return AIL_ERROR_INVALID_PARAMETER;
switch (prop) {
- case E_AIL_PROP_X_SLP_ENABLED_BOOL:
- info->x_slp_enabled = (int)value;
- break;
- default:
- return AIL_ERROR_FAIL;
+ case E_AIL_PROP_X_SLP_ENABLED_BOOL:
+ info->x_slp_enabled = (int)value;
+ break;
+ default:
+ return AIL_ERROR_FAIL;
}
return AIL_ERROR_OK;
const char *property,
const char *value)
{
- ail_prop_bool_e prop;
- int val;
+ int prop;
retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
return AIL_ERROR_INVALID_PARAMETER;
switch (prop) {
- case E_AIL_PROP_NAME_STR:
- SAFE_FREE_AND_STRDUP(value, info->name);
- retv_if (!info->name, AIL_ERROR_OUT_OF_MEMORY);
- break;
- case E_AIL_PROP_X_SLP_SVC_STR:
- SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
- retv_if (!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
- break;
- case E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR:
- SAFE_FREE_AND_STRDUP(value, info->x_slp_installedstorage);
- retv_if (!info->x_slp_installedstorage, AIL_ERROR_OUT_OF_MEMORY);
- break;
- default:
- _E("prop[%d] is not defined\n", prop);
- return AIL_ERROR_FAIL;
+ case E_AIL_PROP_NAME_STR:
+ SAFE_FREE_AND_STRDUP(value, info->name);
+ retv_if(!info->name, AIL_ERROR_OUT_OF_MEMORY);
+ break;
+ case E_AIL_PROP_X_SLP_SVC_STR:
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_svc);
+ retv_if(!info->x_slp_svc, AIL_ERROR_OUT_OF_MEMORY);
+ break;
+ case E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR:
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_installedstorage);
+ retv_if(!info->x_slp_installedstorage, AIL_ERROR_OUT_OF_MEMORY);
+ break;
+ default:
+ _E("prop[%d] is not defined\n", prop);
+ return AIL_ERROR_FAIL;
}
return AIL_ERROR_OK;
sqlite3_snprintf(sizeof(query), query, "insert into localname (package, locale, name, x_slp_pkgid) "
"values ('%q', '%q', '%q', '%q');",
info->package, item->locale, item->name, info->x_slp_pkgid);
- if(uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER) {
if (db_exec_usr_rw(query) < 0)
- _E("Failed to insert local name of package[%s]",info->package);
+ _E("Failed to insert local name of package[%s]", info->package);
} else {
if (db_exec_glo_rw(query) < 0)
- _E("Failed to insert local name of package[%s]",info->package);
+ _E("Failed to insert local name of package[%s]", info->package);
}
}
);
ret = db_open(DB_OPEN_RW, uid);
- if(ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK) {
_E("(tmp == NULL) return\n");
free(query);
return AIL_ERROR_DB_FAILED;
char *query;
int len;
- retv_if (NULL == info, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(NULL == info, AIL_ERROR_INVALID_PARAMETER);
- if (db_open(DB_OPEN_RW, uid) < 0) {
+ if (db_open(DB_OPEN_RW, uid) < 0)
return AIL_ERROR_DB_FAILED;
- }
len = _strlen_desktop_info(info) + (0x01 << 10);
query = calloc(1, len);
retv_if(!query, AIL_ERROR_OUT_OF_MEMORY);
- sqlite3_snprintf ( len, query, "update app_info set "
+ sqlite3_snprintf(len, query, "update app_info set "
"exec='%q', "
"name='%q', "
"type='%q', "
info->desktop,
info->package);
- if(uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER) {
if (db_exec_usr_rw(query) < 0) {
- free (query);
+ free(query);
return AIL_ERROR_DB_FAILED;
}
} else {
if (db_exec_glo_rw(query) < 0) {
- free (query);
+ free(query);
return AIL_ERROR_DB_FAILED;
}
}
snprintf(query, len, "delete from localname where package = '%s'", info->package);
if (uid != GLOBAL_USER) {
if (db_exec_usr_rw(query) < 0) {
- free (query);
+ free(query);
return AIL_ERROR_DB_FAILED;
}
} else {
if (db_exec_glo_rw(query) < 0) {
- free (query);
+ free(query);
return AIL_ERROR_DB_FAILED;
}
}
retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
- if (db_open(DB_OPEN_RW, uid) < 0) {
+ if (db_open(DB_OPEN_RW, uid) < 0)
return AIL_ERROR_DB_FAILED;
- }
size = strlen(package) + (0x01 << 10);
query = calloc(1, size);
snprintf(query, size, "delete from app_info where package = '%s'", package);
- if(uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER) {
if (db_exec_usr_rw(query) < 0) {
free(query);
return AIL_ERROR_DB_FAILED;
}
}
snprintf(query, size, "delete from localname where package = '%s'", package);
- _D("query=%s",query);
+ _D("query=%s", query);
- if(uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER) {
if (db_exec_usr_rw(query) < 0) {
free(query);
return AIL_ERROR_DB_FAILED;
retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
- if (db_open(DB_OPEN_RW, uid) ){
+ if (db_open(DB_OPEN_RW, uid))
return AIL_ERROR_DB_FAILED;
- }
size = strlen(pkgid) + (0x01 << 10);
query = calloc(1, size);
snprintf(query, size, "delete from app_info where x_slp_pkgid = '%s'", pkgid);
- if(uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER) {
if (db_exec_usr_rw(query) < 0) {
free(query);
return AIL_ERROR_DB_FAILED;
}
}
snprintf(query, size, "delete from localname where x_slp_pkgid = '%s'", pkgid);
- _D("query=%s",query);
+ _D("query=%s", query);
- if(uid != GLOBAL_USER) {
+ if (uid != GLOBAL_USER) {
if (db_exec_usr_rw(query) < 0) {
free(query);
return AIL_ERROR_DB_FAILED;
retv_if(!package, AIL_ERROR_INVALID_PARAMETER);
switch (type) {
- case NOTI_ADD:
- type_string = "create";
- break;
- case NOTI_UPDATE:
- type_string = "update";
- break;
- case NOTI_REMOVE:
- type_string = "delete";
- break;
- default:
- return AIL_ERROR_FAIL;
+ case NOTI_ADD:
+ type_string = "create";
+ break;
+ case NOTI_UPDATE:
+ type_string = "update";
+ break;
+ case NOTI_REMOVE:
+ type_string = "delete";
+ break;
+ default:
+ return AIL_ERROR_FAIL;
}
size = snprintf(NULL, 0, "%s:%s:%u", type_string, package, getuid());
return AIL_ERROR_OK;
}
-
-static void inline _name_item_free_func(gpointer data)
+static inline void _name_item_free_func(gpointer data)
{
struct name_item *item = (struct name_item *)data;
- if (item){
+ if (item) {
SAFE_FREE(item->locale);
item->locale = NULL;
SAFE_FREE(item->name);
return;
}
-static int __is_authorized()
-{
- uid_t uid = getuid();
- if ((uid_t) GLOBAL_USER == uid )
- return 1;
- else
- return 0;
-}
-
/* Public functions */
EXPORT_API ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid)
{
EXPORT_API ail_error_e ail_desktop_update(const char *appid)
{
- return ail_usr_desktop_update(appid,GLOBAL_USER);
+ return ail_usr_desktop_update(appid, GLOBAL_USER);
}
-
EXPORT_API ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid)
{
ail_error_e ret;
retv_if(!pkgid, AIL_ERROR_INVALID_PARAMETER);
- _D("ail_desktop_clean=%s",pkgid);
+ _D("ail_desktop_clean=%s", pkgid);
ret = _clean_pkgid_data(pkgid, uid);
retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
if (ret != AIL_ERROR_OK)
goto end;
- ret = _read_desktop_info(&info,uid);
+ ret = _read_desktop_info(&info, uid);
if (ret != AIL_ERROR_OK)
goto end;
{
struct ail_filter *f;
- retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(filter == NULL, AIL_ERROR_INVALID_PARAMETER);
f = (struct ail_filter *)calloc(1, sizeof(struct ail_filter));
- retv_if (NULL == f, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(f == NULL, AIL_ERROR_OUT_OF_MEMORY);
*filter = f;
int t;
ELEMENT_TYPE(cond, t);
if (VAL_TYPE_STR == t) {
- if(ELEMENT_STR(cond)->value)
+ if (ELEMENT_STR(cond)->value)
free(ELEMENT_STR(cond)->value);
}
free(cond);
EXPORT_API ail_error_e ail_filter_destroy(ail_filter_h filter)
{
- retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(filter == NULL, AIL_ERROR_INVALID_PARAMETER);
- if (filter->list){
+ if (filter->list) {
g_slist_foreach(filter->list, _destroy_cond, NULL);
g_slist_free(filter->list);
}
struct element *c;
ail_prop_bool_e prop;
- retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
- retv_if (NULL == property, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(filter == NULL, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(property == NULL, AIL_ERROR_INVALID_PARAMETER);
prop = _ail_convert_to_prop_bool(property);
return AIL_ERROR_INVALID_PARAMETER;
c = (struct element *)calloc(1, sizeof(struct element_bool));
- retv_if (NULL == c, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(c == NULL, AIL_ERROR_OUT_OF_MEMORY);
ELEMENT_BOOL(c)->prop = (int)prop;
ELEMENT_BOOL(c)->value = value;
struct element *c;
ail_prop_int_e prop;
- retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
- retv_if (NULL == property, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(filter == NULL, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(property == NULL, AIL_ERROR_INVALID_PARAMETER);
prop = _ail_convert_to_prop_int(property);
return AIL_ERROR_INVALID_PARAMETER;
c = (struct element *)calloc(1, sizeof(struct element_int));
- retv_if (NULL == c, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(c == NULL, AIL_ERROR_OUT_OF_MEMORY);
ELEMENT_INT(c)->prop = (int)prop;
ELEMENT_INT(c)->value = value;
EXPORT_API ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const char *value)
{
- struct element *c; //condition
+ struct element *c; /* condition */
ail_prop_str_e prop;
- retv_if (NULL == filter, AIL_ERROR_INVALID_PARAMETER);
- retv_if (NULL == property, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(filter == NULL, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(property == NULL, AIL_ERROR_INVALID_PARAMETER);
prop = _ail_convert_to_prop_str(property);
if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_STR_MAX)
return AIL_ERROR_INVALID_PARAMETER;
- retv_if (NULL == value, AIL_ERROR_INVALID_PARAMETER);
- retv_if (strlen(value) == 0, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(value == NULL, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(strlen(value) == 0, AIL_ERROR_INVALID_PARAMETER);
c = (struct element *)calloc(1, sizeof(struct element_str));
-
- retv_if (NULL == c, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(c == NULL, AIL_ERROR_OUT_OF_MEMORY);
ELEMENT_STR(c)->prop = (int)prop;
ELEMENT_STR(c)->value = strdup(value);
ELEMENT_TYPE(e, t);
switch (t) {
- case VAL_TYPE_BOOL:
- snprintf(buf, sizeof(buf), f, ELEMENT_BOOL(e)->value);
- break;
- case VAL_TYPE_INT:
- snprintf(buf, sizeof(buf), f, ELEMENT_INT(e)->value);
- break;
- case VAL_TYPE_STR:
- if (E_AIL_PROP_NAME_STR == e->prop) {
- snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value, ELEMENT_STR(e)->value);
- } else {
- snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value);
- }
- break;
- default:
- _E("Invalid property type");
- *condition = NULL;
- return;
+ case VAL_TYPE_BOOL:
+ snprintf(buf, sizeof(buf), f, ELEMENT_BOOL(e)->value);
+ break;
+ case VAL_TYPE_INT:
+ snprintf(buf, sizeof(buf), f, ELEMENT_INT(e)->value);
+ break;
+ case VAL_TYPE_STR:
+ if (E_AIL_PROP_NAME_STR == e->prop)
+ snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value, ELEMENT_STR(e)->value);
+ else
+ snprintf(buf, sizeof(buf), f, ELEMENT_STR(e)->value);
+ break;
+ default:
+ _E("Invalid property type");
+ *condition = NULL;
+ return;
}
*condition = strdup(buf);
for (l = filter->list; l; l = g_slist_next(l)) {
_get_condition(l->data, &c);
- if (!c) return NULL;
+ if (!c)
+ return NULL;
if (*c == 0) {
free(c);
return NULL;
}
strncat(w, c, sizeof(w)-strlen(w)-1);
- w[sizeof(w)-1] = '\0';
- if(c) free(c);
+ w[sizeof(w) - 1] = '\0';
+ if (c) {
+ free(c);
+ c = NULL;
+ }
if (g_slist_next(l)) {
strncat(w, " and ", sizeof(w)-strlen(w)-1);
- w[sizeof(w)-1] = '\0';
+ w[sizeof(w) - 1] = '\0';
}
}
-// _D("where = %s", w);
-
return strdup(w);
}
char *w;
char *tmp_q;
char *l;
- ail_cb_ret_e r;
sqlite3_stmt *stmt;
ail_appinfo_h ai;
int filter_count = 0;
snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
tmp_q = strdup(q);
- retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(tmp_q == NULL, AIL_ERROR_OUT_OF_MEMORY);
l = sql_get_locale();
- if (NULL == l) {
+ if (l == NULL) {
_E("Failed to get locale string");
free(tmp_q);
return AIL_ERROR_FAIL;
if (filter && filter->list) {
w = _get_where_clause(filter);
- retv_if (NULL == w, AIL_ERROR_FAIL);
+ retv_if(w == NULL, AIL_ERROR_FAIL);
strncat(q, w, sizeof(q)-strlen(q)-1);
q[sizeof(q)-1] = '\0';
free(w);
- }
- else
+ } else {
_D("No filter exists. All records are retreived");
+ }
-//is_admin
+ /* is_admin */
if (db_prepare_globalro(q, &stmt) != AIL_ERROR_OK) {
- _E("db_prepare_globalro fail for query = %s",q);
+ _E("db_prepare_globalro fail for query = %s", q);
return AIL_ERROR_DB_FAILED;
}
ai = appinfo_create();
appinfo_set_stmt(ai, stmt);
while (db_step(stmt) == AIL_ERROR_OK) {
- if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
+ if (_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
continue;
filter_count++;
char *w;
char *tmp_q;
char *l;
- ail_cb_ret_e r;
sqlite3_stmt *stmt;
ail_appinfo_h ai;
int filter_count = 0;
retv_if(!cnt, AIL_ERROR_INVALID_PARAMETER);
-//is_admin ; redirect
+ /* is_admin ; redirect */
if (uid == GLOBAL_USER)
return ail_filter_count_appinfo(filter, cnt);
snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
tmp_q = strdup(q);
- retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(tmp_q == NULL, AIL_ERROR_OUT_OF_MEMORY);
l = sql_get_locale();
if (NULL == l) {
_E("Failed to get locale string");
if (filter && filter->list) {
w = _get_where_clause(filter);
- retv_if (NULL == w, AIL_ERROR_FAIL);
- strncat(q, w, sizeof(q)-strlen(q)-1);
+ retv_if(w == NULL, AIL_ERROR_FAIL);
+ strncat(q, w, sizeof(q) - strlen(q) - 1);
q[sizeof(q)-1] = '\0';
free(w);
- }
- else
+ } else {
_D("No filter exists. All records are retreived");
+ }
if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
- _E("db_prepare fail for query = %s",q);
+ _E("db_prepare fail for query = %s", q);
return AIL_ERROR_DB_FAILED;
}
appinfo_set_stmt(ai, stmt);
while (db_step(stmt) == AIL_ERROR_OK) {
-
- if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
+ if (_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
continue;
filter_count++;
sqlite3_stmt *stmt;
ail_appinfo_h ai;
- retv_if (NULL == cb, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(cb == NULL, AIL_ERROR_INVALID_PARAMETER);
if (db_open(DB_OPEN_RO, GLOBAL_USER) != AIL_ERROR_OK)
return AIL_ERROR_DB_FAILED;
snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
tmp_q = strdup(q);
- retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(tmp_q == NULL, AIL_ERROR_OUT_OF_MEMORY);
l = sql_get_locale();
- if (NULL == l) {
+ if (l == NULL) {
_E("Failed to get locale string");
free(tmp_q);
return AIL_ERROR_FAIL;
if (filter && filter->list) {
w = _get_where_clause(filter);
- retv_if (NULL == w, AIL_ERROR_FAIL);
+ retv_if(w == NULL, AIL_ERROR_FAIL);
strncat(q, w, sizeof(q)-strlen(q)-1);
- q[sizeof(q)-1] = '\0';
- strncat(q, " order by app_info.package", sizeof(q)-strlen(q)-1);
- q[sizeof(q)-1] = '\0';
+ q[sizeof(q) - 1] = '\0';
+ strncat(q, " order by app_info.package", sizeof(q) - strlen(q) - 1);
+ q[sizeof(q) - 1] = '\0';
free(w);
- }
- else
+ } else {
_D("No filter exists. All records are retreived");
+ }
-// _D("Query = %s",q);
-//is_admin
+ /* is_admin */
if (db_prepare_globalro(q, &stmt) != AIL_ERROR_OK) {
- _E("db_prepare fail for query = %s",q);
+ _E("db_prepare fail for query = %s", q);
return AIL_ERROR_DB_FAILED;
}
- /*if (db_prepare_globalro(q, &stmt) != AIL_ERROR_OK) {
+ /* if (db_prepare_globalro(q, &stmt) != AIL_ERROR_OK) {
_E("db_prepare fail for query = %s",q);
return AIL_ERROR_DB_FAILED;
}*/
appinfo_set_stmt(ai, stmt);
uint i = 0;
- while (i = db_step(stmt) == AIL_ERROR_OK) {
+ while ((i = db_step(stmt)) == AIL_ERROR_OK) {
_E("------------------------dbstep : %u\n", i);
- if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
+ if (_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
continue;
- r = cb(ai, user_data,GLOBAL_USER);
+ r = cb(ai, user_data, GLOBAL_USER);
if (AIL_CB_RET_CANCEL == r)
break;
}
sqlite3_stmt *stmt;
ail_appinfo_h ai;
- retv_if (NULL == cb, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(cb == NULL, AIL_ERROR_INVALID_PARAMETER);
if (db_open(DB_OPEN_RO, uid) != AIL_ERROR_OK)
return AIL_ERROR_DB_FAILED;
snprintf(q, sizeof(q), "SELECT %s FROM %s", SQL_FLD_APP_INFO_WITH_LOCALNAME, SQL_TBL_APP_INFO_WITH_LOCALNAME);
tmp_q = strdup(q);
- retv_if (NULL == tmp_q, AIL_ERROR_OUT_OF_MEMORY);
+ retv_if(tmp_q == NULL, AIL_ERROR_OUT_OF_MEMORY);
l = sql_get_locale();
- if (NULL == l) {
+ if (l == NULL) {
_E("Failed to get locale string");
free(tmp_q);
return AIL_ERROR_FAIL;
if (filter && filter->list) {
w = _get_where_clause(filter);
- retv_if (NULL == w, AIL_ERROR_FAIL);
- strncat(q, w, sizeof(q)-strlen(q)-1);
- q[sizeof(q)-1] = '\0';
- strncat(q, " order by app_info.package", sizeof(q)-strlen(q)-1);
- q[sizeof(q)-1] = '\0';
+ retv_if(w == NULL, AIL_ERROR_FAIL);
+ strncat(q, w, sizeof(q) - strlen(q) - 1);
+ q[sizeof(q) - 1] = '\0';
+ strncat(q, " order by app_info.package", sizeof(q) - strlen(q) - 1);
+ q[sizeof(q) - 1] = '\0';
free(w);
- }
- else
+ } else {
_D("No filter exists. All records are retreived");
+ }
-//is_admin
+ /* is_admin */
if (db_prepare(q, &stmt) != AIL_ERROR_OK) {
- _E("db_prepare fail for query = %s",q);
+ _E("db_prepare fail for query = %s", q);
return AIL_ERROR_DB_FAILED;
}
appinfo_set_stmt(ai, stmt);
uint i = 0;
- while (i = db_step(stmt) == AIL_ERROR_OK) {
- if(_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
+ while ((i = db_step(stmt)) == AIL_ERROR_OK) {
+ if (_appinfo_check_installed_storage(ai) != AIL_ERROR_OK)
continue;
- r = cb(ai, user_data,uid);
+ r = cb(ai, user_data, uid);
if (AIL_CB_RET_CANCEL == r)
break;
}
#include <string.h>
#include <stdlib.h>
+#include <ctype.h>
+#include <assert.h>
+#include <unistd.h>
#include <db-util.h>
#include <tzplatform_config.h>
#include <vconf.h>
+
#include "ail.h"
#include "ail_private.h"
#include "ail_convert.h"
#include "ail_db.h"
#include "ail_sql.h"
#include "ail_package.h"
-#include <assert.h>
-#include <unistd.h>
#define LANGUAGE_LENGTH 2
#define DEFAULT_LOCALE "No Locale"
char *locale;
} pkgmgr_locale_x;
-
/* get the first locale value*/
static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
{
static int __check_validation_of_query_cb(void *data, int ncols, char **coltxt, char **colname)
{
- int *p = (int*)data;
+ int *p = (int *)data;
*p = atoi(coltxt[0]);
return 0;
}
static int __check_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale)
{
int result_query = -1;
- char wildcard[2] = {'%','\0'};
+ char wildcard[2] = {'%', '\0'};
char query[MAX_QUERY_LEN];
char lang[3] = {'\0'};
strncpy(lang, locale, LANGUAGE_LENGTH);
static char* __get_app_locale_from_app_localized_info_by_fallback(const char *appid, const char *locale)
{
- char wildcard[2] = {'%','\0'};
+ char wildcard[2] = {'%', '\0'};
char lang[3] = {'\0'};
char query[MAX_QUERY_LEN];
char *locale_new = NULL;
_E("Out of Memory!!!\n");
return NULL;
}
- memset(info, NULL, sizeof(*info));
+ memset(info, 0x00, sizeof(*info));
strncpy(lang, locale, 2);
snprintf(query, MAX_QUERY_LEN, "select locale from localname where package='%s' and locale like '%s%s'", appid, lang, wildcard);
return locale_new;
}
-static char* __convert_syslocale_to_manifest_locale(char *syslocale)
+static char* __convert_syslocale_to_manifest_locale(const char *syslocale)
{
char *locale = malloc(6);
if (!locale) {
/* fallback matching */
check_result = __check_app_locale_from_app_localized_info_by_fallback(appid, locale);
- if(check_result == 1) {
+ if (check_result == 1) {
locale_new = __get_app_locale_from_app_localized_info_by_fallback(appid, locale);
_D("%s found (%s) language-locale in DB by fallback!\n", appid, locale_new);
free(locale);
for (i = 0; i < NUM_OF_PROP; i++) {
err = db_column_str(ai->stmt, i, &col);
- if (AIL_ERROR_OK != err)
+ if (AIL_ERROR_OK != err)
break;
if (!col) {
if (ai->stmt) {
prop = _ail_convert_to_prop_str(AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR);
index = sql_get_app_info_idx(prop);
- if (db_column_str(ai->stmt, index, &installed_storage) < 0){
+ if (db_column_str(ai->stmt, index, &installed_storage) < 0)
return AIL_ERROR_OK;
- }
prop = _ail_convert_to_prop_str(AIL_PROP_X_SLP_PKGID_STR);
index = sql_get_app_info_idx(prop);
- if (db_column_str(ai->stmt, index, &pkgid) < 0){
+ if (db_column_str(ai->stmt, index, &pkgid) < 0)
return AIL_ERROR_OK;
- }
} else {
prop = _ail_convert_to_prop_str(AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR);
installed_storage = ai->values[prop];
snprintf(buf, AIL_SQL_QUERY_MAX_LEN - 1, "%s%s", PKG_SD_PATH, pkgid);
if (access(buf, R_OK) != 0) {
_E("can not access [%s]", buf);
- return AIL_ERROR_OK;//tmep, it will be fixed to :: return AIL_ERROR_FAIL;
+ return AIL_ERROR_OK; /* tmep, it will be fixed to :: return AIL_ERROR_FAIL; */
}
}
{
ail_appinfo_h ai;
ai = calloc(1, sizeof(struct ail_appinfo));
- retv_if (NULL == ai, NULL);
+ retv_if(ai == NULL, NULL);
ai->stmt = NULL;
return ai;
retv_if(!ai->values, AIL_ERROR_INVALID_PARAMETER);
for (i = 0; i < NUM_OF_PROP; i++) {
- if (ai->values[i]) {
+ if (ai->values[i])
free(ai->values[i]);
- }
}
free(ai->values);
return AIL_ERROR_DB_FAILED;
} else {
val = atoi(ai->values[prop]);
- *value = (val == 0? false : true);
+ *value = (val == 0) ? false : true;
}
return AIL_ERROR_OK;
}
snprintf(query, sizeof(query), QUERY_GET_LOCALNAME, package, locale);
if (uid != GLOBAL_USER)
- retv_if (db_prepare(query, &stmt) < 0, NULL);
+ retv_if(db_prepare(query, &stmt) < 0, NULL);
else
- retv_if (db_prepare_globalro(query, &stmt) < 0, NULL);
+ retv_if(db_prepare_globalro(query, &stmt) < 0, NULL);
do {
if (db_step(stmt) < 0)
db_finalize(stmt);
return localname;
- } while(0);
+ } while (0);
db_finalize(stmt);
return NULL;
if (ai->stmt) {
if (db_column_str(ai->stmt, E_AIL_PROP_X_SLP_PACKAGETYPE_STR, &pkg_type) < 0)
return AIL_ERROR_DB_FAILED;
- if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
- {
+ if (pkg_type && (strcasecmp(pkg_type, "tpk") == 0)) {
locale = sql_get_locale();
- retv_if (NULL == locale, AIL_ERROR_FAIL);
+ retv_if(locale == NULL, AIL_ERROR_FAIL);
- if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+ if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0) {
free(locale);
return AIL_ERROR_DB_FAILED;
}
- if (pkg == NULL){
+ if (pkg == NULL) {
free(locale);
return AIL_ERROR_DB_FAILED;
}
} else {
pkg_type = ai->values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR];
pkg = ai->values[E_AIL_PROP_PACKAGE_STR];
- retv_if (NULL == pkg, AIL_ERROR_FAIL);
+ retv_if(pkg == NULL, AIL_ERROR_FAIL);
locale = sql_get_locale();
- retv_if (NULL == locale, AIL_ERROR_FAIL);
+ retv_if(locale == NULL, AIL_ERROR_FAIL);
- if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
- {
+ if (pkg_type && (strcasecmp(pkg_type, "tpk") == 0)) {
locale_new = __get_app_locale_by_fallback(pkg, locale);
localname = (char *)appinfo_get_localname(pkg, locale_new, GLOBAL_USER);
free(locale);
if (ai->stmt) {
index = sql_get_app_info_idx(prop);
- if (db_column_str(ai->stmt, index, &value) < 0){
+ if (db_column_str(ai->stmt, index, &value) < 0)
return AIL_ERROR_DB_FAILED;
- }
+
*str = value;
} else
*str = ai->values[prop];
return AIL_ERROR_OK;
}
+
EXPORT_API ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h ai, const char *property, uid_t uid, char **str)
{
int index;
if (ai->stmt) {
if (db_column_str(ai->stmt, E_AIL_PROP_X_SLP_PACKAGETYPE_STR, &pkg_type) < 0)
return AIL_ERROR_DB_FAILED;
- if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
- {
+ if (pkg_type && (strcasecmp(pkg_type, "tpk") == 0)) {
locale = sql_get_locale();
- retv_if (NULL == locale, AIL_ERROR_FAIL);
+ retv_if(locale == NULL, AIL_ERROR_FAIL);
- if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0){
+ if (db_column_str(ai->stmt, E_AIL_PROP_PACKAGE_STR, &pkg) < 0) {
free(locale);
return AIL_ERROR_DB_FAILED;
}
- if (pkg == NULL){
+ if (pkg == NULL) {
free(locale);
return AIL_ERROR_DB_FAILED;
}
} else {
pkg_type = ai->values[E_AIL_PROP_X_SLP_PACKAGETYPE_STR];
pkg = ai->values[E_AIL_PROP_PACKAGE_STR];
- retv_if (NULL == pkg, AIL_ERROR_FAIL);
+ retv_if(pkg == NULL, AIL_ERROR_FAIL);
locale = sql_get_locale();
- retv_if (NULL == locale, AIL_ERROR_FAIL);
+ retv_if(locale == NULL, AIL_ERROR_FAIL);
- if(pkg_type && (strcasecmp(pkg_type, "tpk") ==0))
- {
+ if (pkg_type && (strcasecmp(pkg_type, "tpk") == 0)) {
locale_new = __get_app_locale_by_fallback(pkg, locale);
localname = (char *)appinfo_get_localname(pkg, locale_new, uid);
free(locale);
if (ai->stmt) {
index = sql_get_app_info_idx(prop);
- if (db_column_str(ai->stmt, index, &value) < 0){
+ if (db_column_str(ai->stmt, index, &value) < 0)
return AIL_ERROR_DB_FAILED;
- }
+
*str = value;
} else
*str = ai->values[prop];
return AIL_ERROR_OK;
}
-
EXPORT_API ail_error_e ail_close_appinfo_db(void)
{
return db_close();
}
-
-// End of file
ail_appinfo_h appinfo_create(void);
void appinfo_destroy(ail_appinfo_h ai);
void appinfo_set_stmt(ail_appinfo_h ai, sqlite3_stmt *stmt);
+int _appinfo_check_installed_storage(ail_appinfo_h ai);
#endif /* __AIL_PACKAGE_H__ */
NULL,
};
-
inline const char *sql_get_filter(int prop)
{
retv_if(prop < 0 || prop >= NUM_OF_PROP , NULL);
char *r;
char buf[6];
- retv_if ((l = ail_vconf_get_str(VCONFKEY_LANGSET)) == NULL, NULL);
+ retv_if((l = ail_vconf_get_str(VCONFKEY_LANGSET)) == NULL, NULL);
snprintf(buf, sizeof(buf), "%s", l);
free(l);
{
return prop;
}
-
-// End of file
#define CMD_VCONF_SET_STR VCONFTOOL " -q set -t string '%s' '%s' -f"
/*
-
- Reads the content of the input 'stream' (it should be a text without nul
-characters) in a feshly allocated buffer, using allocations of 'block_size'
-increment.
-
- Returns the read string or NULL in case of error.
-*/
+ * Reads the content of the input 'stream' (it should be a text without nul
+ * characters) in a feshly allocated buffer, using allocations of 'block_size'
+ * increment.
+ * Returns the read string or NULL in case of error.
+ */
static char *_pread_(FILE *stream, size_t block_size)
{
char *result = NULL;
size_t length = 0;
char *string;
- for(;;) {
+ for (;;) {
/* is on error ? */
if (ferror(stream) != 0) {
free(result);
}
/*
- Runs the command given by 'cmddef' and its arguments formated as printf.
-
- The resulting output stream of the command is return as a freshly allocated
-string in '*readen'.
-
- Retruns 0 in case of success or -1 in case of error.
-*/
+ * Runs the command given by 'cmddef' and its arguments formated as printf.
+ * The resulting output stream of the command is return as a freshly allocated
+ * string in '*readen'.
+ * Retruns 0 in case of success or -1 in case of error.
+ */
static int _ail_vconf_exec_(char **readen, const char *cmddef, ...)
{
int result;
stream = popen(command, "r");
if (stream != NULL) {
*readen = _pread_(stream, 1024);
- if (pclose(stream) != -1 && *readen != NULL) {
+ if (pclose(stream) != -1 && *readen != NULL)
result = 0;
- }
}
free(command);
}
}
/*
- vconf_get_str with fallback to the command vconftool.
-*/
+ * vconf_get_str with fallback to the command vconftool.
+ */
EXPORT_API char *ail_vconf_get_str(const char *keyname)
{
char *result;
result = result + 3;
/* remove trailing '\n' */
length = strlen(result);
- if (length > 0 && result[length-1] == '\n') {
- result[length-1] = 0;
- }
+ if (length > 0 && result[length-1] == '\n')
+ result[length - 1] = 0;
/* get the final result */
result = strdup(result);
}
}
/*
- vconf_set_str with fallback to the command vconftool.
-*/
+ * vconf_set_str with fallback to the command vconftool.
+ */
EXPORT_API int ail_vconf_set_str(const char *keyname, const char *strval)
{
int result;
}
#endif
-
-
-
#include <ail.h>
-
static void _print_help(const char *cmd)
{
fprintf(stderr, "Usage:\n");
fprintf(stderr, "\n");
}
-
-
static ail_error_e _add_desktop(const char *package)
{
ail_error_e ret;
- if (!package) {
+ if (!package)
return AIL_ERROR_FAIL;
- }
ret = ail_desktop_add(package);
- if (ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK)
return AIL_ERROR_FAIL;
- }
return AIL_ERROR_OK;
}
-
-
static ail_error_e _update_desktop(const char *package)
{
ail_error_e ret;
- if (!package) {
+ if (!package)
return AIL_ERROR_FAIL;
- }
ret = ail_desktop_update(package);
- if (ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK)
return AIL_ERROR_FAIL;
- }
return AIL_ERROR_OK;
}
-
-
static ail_error_e _remove_desktop(const char *package)
{
ail_error_e ret;
- if (!package) {
+ if (!package)
return AIL_ERROR_FAIL;
- }
ret = ail_desktop_remove(package);
- if (ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK)
return AIL_ERROR_FAIL;
- }
return AIL_ERROR_OK;
}
-
-
-int main(int argc, char** argv)
+int main(int argc, char **argv)
{
ail_error_e ret = AIL_ERROR_OK;
if (3 == argc) {
- if (!strncmp(argv[1], "add", 3)) {
+ if (!strncmp(argv[1], "add", 3))
ret = _add_desktop(argv[2]);
- } else if (!strncmp(argv[1], "update", 6)) {
+ else if (!strncmp(argv[1], "update", 6))
ret = _update_desktop(argv[2]);
- } else if (!strncmp(argv[1], "remove", 6)) {
+ else if (!strncmp(argv[1], "remove", 6))
ret = _remove_desktop(argv[2]);
- } else {
+ else
fprintf(stderr, "%s is a invalid command\n", argv[1]);
- }
- }
- else {
+ } else {
_print_help(argv[0]);
return EXIT_FAILURE;
}
- if (ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK)
fprintf(stderr, "There are some problems\n");
- }
return EXIT_SUCCESS;
}
-
};
static struct _ail_map_t prop_map[] = {
- {E_AIL_PROP_PACKAGE_STR, AIL_PROP_PACKAGE_STR},
- {E_AIL_PROP_EXEC_STR, AIL_PROP_EXEC_STR},
- {E_AIL_PROP_NAME_STR, AIL_PROP_NAME_STR},
- {E_AIL_PROP_TYPE_STR, AIL_PROP_TYPE_STR},
- {E_AIL_PROP_ICON_STR, AIL_PROP_ICON_STR},
- {E_AIL_PROP_CATEGORIES_STR, AIL_PROP_CATEGORIES_STR},
- {E_AIL_PROP_VERSION_STR, AIL_PROP_VERSION_STR},
- {E_AIL_PROP_MIMETYPE_STR, AIL_PROP_MIMETYPE_STR},
- {E_AIL_PROP_X_SLP_SERVICE_STR, AIL_PROP_X_SLP_SERVICE_STR},
- {E_AIL_PROP_X_SLP_PACKAGETYPE_STR, AIL_PROP_X_SLP_PACKAGETYPE_STR},
+ {E_AIL_PROP_PACKAGE_STR, AIL_PROP_PACKAGE_STR},
+ {E_AIL_PROP_EXEC_STR, AIL_PROP_EXEC_STR},
+ {E_AIL_PROP_NAME_STR, AIL_PROP_NAME_STR},
+ {E_AIL_PROP_TYPE_STR, AIL_PROP_TYPE_STR},
+ {E_AIL_PROP_ICON_STR, AIL_PROP_ICON_STR},
+ {E_AIL_PROP_CATEGORIES_STR, AIL_PROP_CATEGORIES_STR},
+ {E_AIL_PROP_VERSION_STR, AIL_PROP_VERSION_STR},
+ {E_AIL_PROP_MIMETYPE_STR, AIL_PROP_MIMETYPE_STR},
+ {E_AIL_PROP_X_SLP_SERVICE_STR, AIL_PROP_X_SLP_SERVICE_STR},
+ {E_AIL_PROP_X_SLP_PACKAGETYPE_STR, AIL_PROP_X_SLP_PACKAGETYPE_STR},
{E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR, AIL_PROP_X_SLP_PACKAGECATEGORIES_STR},
- {E_AIL_PROP_X_SLP_PACKAGEID_STR, AIL_PROP_X_SLP_PACKAGEID_STR},
- {E_AIL_PROP_X_SLP_SVC_STR, AIL_PROP_X_SLP_SVC_STR},
- {E_AIL_PROP_X_SLP_EXE_PATH, AIL_PROP_X_SLP_EXE_PATH},
+ {E_AIL_PROP_X_SLP_PACKAGEID_STR, AIL_PROP_X_SLP_PACKAGEID_STR},
+ {E_AIL_PROP_X_SLP_SVC_STR, AIL_PROP_X_SLP_SVC_STR},
+ {E_AIL_PROP_X_SLP_EXE_PATH, AIL_PROP_X_SLP_EXE_PATH},
{E_AIL_PROP_NODISPLAY_BOOL, AIL_PROP_NODISPLAY_BOOL},
{E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_NODISPLAY_BOOL},
{E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
static const char *_ail_convert_to_property(int prop)
{
- int i = 0;
+ int i;
if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_BOOL_MAX)
return NULL;
- for (i=0 ; i < (E_AIL_PROP_BOOL_MAX + 1) ; i++) {
- if (prop == prop_map[i].prop) {
+ for (i = 0 ; i < (E_AIL_PROP_BOOL_MAX + 1) ; i++) {
+ if (prop == prop_map[i].prop)
return prop_map[i].property;
- }
}
return NULL;
}
-
-
static int _get_cmd(const char *arg)
{
int r;
int a;
- if(!arg)
+ if (!arg)
a = 0;
else
a = (int)*arg;
return r;
}
-ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data)
+static ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data, uid_t uid)
{
char *rs = NULL;
- int t=-1;
+ int t = -1;
bool b = 0;
int n = 0;
struct element e;
- int i=0;
+ int i = 0;
struct element *p;
+ bool err = false;
ail_error_e error = AIL_ERROR_OK;
ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
p = &e;
- bool err = false;
ret = AIL_CB_RET_CONTINUE;
- for(i = 0; i< E_AIL_PROP_BOOL_MAX+1 && err==false; i ++) {
+ for (i = 0; i < E_AIL_PROP_BOOL_MAX + 1 && err == false; i++) {
e.prop = i;
ELEMENT_TYPE(p, t);
- switch(t) {
- case VAL_TYPE_BOOL:
- error = ail_appinfo_get_bool(appinfo, _ail_convert_to_property(i), &b);
- if (error) ret = AIL_CB_RET_CANCEL;
- printf("%s|",b?"true":"false");
- break;
- case VAL_TYPE_INT:
- ail_appinfo_get_int(appinfo, _ail_convert_to_property(i), &n);
- if (error) ret = AIL_CB_RET_CANCEL;
- printf("%d|", n);
- break;
- case VAL_TYPE_STR:
- ail_appinfo_get_str(appinfo, _ail_convert_to_property(i), &rs);
- if (error) ret = AIL_CB_RET_CANCEL;
- printf("%s|", rs);
- break;
- default:
- fprintf(stderr, "$$$\n");
- err = true;
- break;
+ switch (t) {
+ case VAL_TYPE_BOOL:
+ error = ail_appinfo_get_bool(appinfo, _ail_convert_to_property(i), &b);
+ if (error)
+ ret = AIL_CB_RET_CANCEL;
+ printf("%s|", b ? "true" : "false");
+ break;
+ case VAL_TYPE_INT:
+ ail_appinfo_get_int(appinfo, _ail_convert_to_property(i), &n);
+ if (error)
+ ret = AIL_CB_RET_CANCEL;
+ printf("%d|", n);
+ break;
+ case VAL_TYPE_STR:
+ ail_appinfo_get_str(appinfo, _ail_convert_to_property(i), &rs);
+ if (error)
+ ret = AIL_CB_RET_CANCEL;
+ printf("%s|", rs);
+ break;
+ default:
+ fprintf(stderr, "$$$\n");
+ err = true;
+ break;
}
}
+
printf("\n");
return ret;
}
-
-
int main(int argc, char *argv[])
{
int o;
ELEMENT_TYPE(p, t);
switch (o) {
- case 'c':
- c = _get_cmd(optarg);
- break;
- case 0:
- switch (t) {
- case VAL_TYPE_BOOL:
- if(!strcasecmp(optarg, "true") || !strcasecmp(optarg, "1"))
- b = true;
- else if (!strcasecmp(optarg, "false") || !strcasecmp(optarg, "0"))
- b = false;
- else {
- err = true;
- break;
- }
- if (ail_filter_add_bool(f, _ail_convert_to_property(e.prop), b) != AIL_ERROR_OK)
- err = true;
- break;
-
- case VAL_TYPE_INT:
- if (ail_filter_add_int(f, _ail_convert_to_property(e.prop), atoi(optarg)) != AIL_ERROR_OK)
- err = true;
- break;
-
- case VAL_TYPE_STR:
- if (ail_filter_add_str(f, _ail_convert_to_property(e.prop), optarg) != AIL_ERROR_OK)
- err = true;
- break;
-
- default:
- err = true;
- break;
+ case 'c':
+ c = _get_cmd(optarg);
+ break;
+ case 0:
+ switch (t) {
+ case VAL_TYPE_BOOL:
+ if (!strcasecmp(optarg, "true") || !strcasecmp(optarg, "1"))
+ b = true;
+ else if (!strcasecmp(optarg, "false") || !strcasecmp(optarg, "0"))
+ b = false;
+ else {
+ err = true;
+ break;
}
+
+ if (ail_filter_add_bool(f, _ail_convert_to_property(e.prop), b) != AIL_ERROR_OK)
+ err = true;
+ break;
+ case VAL_TYPE_INT:
+ if (ail_filter_add_int(f, _ail_convert_to_property(e.prop), atoi(optarg)) != AIL_ERROR_OK)
+ err = true;
+ break;
+ case VAL_TYPE_STR:
+ if (ail_filter_add_str(f, _ail_convert_to_property(e.prop), optarg) != AIL_ERROR_OK)
+ err = true;
break;
default:
err = true;
break;
+ }
+ break;
+ default:
+ err = true;
+ break;
}
}
- if (err) {
+ if (err)
usage(argv[0]);
- }
else {
int n = -1;
switch (c) {
- case _CMD_COUNT:
- if (ail_filter_count_appinfo(f, &n) != AIL_ERROR_OK){
- fprintf(stderr, "Error: failed to count appinfo\n");
- }
- else
- fprintf(stderr, "count=%d\n", n);
- break;
- case _CMD_FILTER:
- ail_filter_list_appinfo_foreach(f, appinfo_list_func, NULL);
- break;
- default:
- break;
+ case _CMD_COUNT:
+ if (ail_filter_count_appinfo(f, &n) != AIL_ERROR_OK)
+ fprintf(stderr, "Error: failed to count appinfo\n");
+ else
+ fprintf(stderr, "count=%d\n", n);
+ break;
+ case _CMD_FILTER:
+ ail_filter_list_appinfo_foreach(f, appinfo_list_func, NULL);
+ break;
+ default:
+ break;
}
}
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <errno.h>
#include <sys/smack.h>
#ifdef _E
#undef _E
#endif
-#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#ifdef _D
#undef _D
#endif
-#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#define SET_DEFAULT_LABEL(x) \
- if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \
- else _D("chsmack -a \"*\" %s", x)
+ do { \
+ if (smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) \
+ _E("failed chsmack -a \"*\" %s", x); \
+ else \
+ _D("chsmack -a \"*\" %s", x); \
+ } while (0)
static int initdb_count_app(uid_t uid)
{
int total = 0;
ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK)
return -1;
- }
ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
if (ret != AIL_ERROR_OK) {
ail_filter_destroy(filter);
return -1;
}
-//__isadmin
- if (uid != GLOBAL_USER)
- ret = ail_filter_count_usr_appinfo(filter, &total, uid);
+
+ /* __isadmin */
+ if (uid != GLOBAL_USER)
+ ret = ail_filter_count_usr_appinfo(filter, &total, uid);
else
- ret = ail_filter_count_appinfo(filter, &total);
+ ret = ail_filter_count_appinfo(filter, &total);
if (ret != AIL_ERROR_OK) {
ail_filter_destroy(filter);
return -1;
return total;
}
-
-
-char* _desktop_to_package(const char* desktop)
+char *_desktop_to_package(const char* desktop)
{
- char *package, *tmp;
+ char *package;
+ char *tmp;
retv_if(!desktop, NULL);
retv_if(!package, NULL);
tmp = strrchr(package, '.');
- if(tmp == NULL) {
+ if (tmp == NULL) {
_E("[%s] is not a desktop file", package);
free(package);
return NULL;
{
DIR *dir;
struct dirent entry, *result;
- int len, ret;
+ int ret;
char buf[BUFSZE];
int total_cnt = 0;
int ok_cnt = 0;
- // desktop file
+ /* desktop file */
dir = opendir(directory);
if (!dir) {
if (strerror_r(errno, buf, sizeof(buf)) == 0)
return AIL_ERROR_FAIL;
}
- len = strlen(directory) + 1;
_D("Loading desktop files from %s", directory);
for (ret = readdir_r(dir, &entry, &result);
continue;
}
- if (ail_desktop_fota(package) != AIL_ERROR_OK) {
+ if (ail_desktop_fota(package) != AIL_ERROR_OK)
_E("Failed to add a package[%s]", package);
- } else {
+ else
ok_cnt++;
- }
free(package);
}
uid_t uid = getuid();
uid_t euid = geteuid();
- //euid need to be root to allow smack label changes during initialization
- if (((uid_t) GLOBAL_USER == uid) && (euid == OWNER_ROOT) )
+ /* euid need to be root to allow smack label changes during initialization */
+ if (((uid_t) GLOBAL_USER == uid) && (euid == OWNER_ROOT))
return 1;
else
return 0;
if (!__is_authorized()) {
fprintf(stderr, "You are not an authorized user!\n");
_D("You are not root user!\n");
- }
- else {
- if(remove(APP_INFO_DB_FILE))
- _E(" %s is not removed",APP_INFO_DB_FILE);
- if(remove(APP_INFO_DB_FILE_JOURNAL))
- _E(" %s is not removed",APP_INFO_DB_FILE_JOURNAL);
+ } else {
+ if (remove(APP_INFO_DB_FILE))
+ _E(" %s is not removed", APP_INFO_DB_FILE);
+ if (remove(APP_INFO_DB_FILE_JOURNAL))
+ _E(" %s is not removed", APP_INFO_DB_FILE_JOURNAL);
}
ret = setenv("AIL_INITDB", "1", 1);
_D("AIL_INITDB : %d", ret);
ret = initdb_count_app(getuid());
- if (ret > 0) {
+ if (ret > 0)
_D("Some Apps in the App Info DB.");
- }
ret = initdb_load_directory(USR_DESKTOP_DIRECTORY);
- if (ret == AIL_ERROR_FAIL) {
+ if (ret == AIL_ERROR_FAIL)
_E("cannot load usr desktop directory.");
- }
if (__is_authorized()) {
ret = initdb_change_perm(APP_INFO_DB_FILE);
- if (ret == AIL_ERROR_FAIL) {
+ if (ret == AIL_ERROR_FAIL)
_E("cannot chown.");
- }
+
SET_DEFAULT_LABEL(APP_INFO_DB_FILE);
SET_DEFAULT_LABEL(APP_INFO_DB_FILE_JOURNAL);
}
+
return AIL_ERROR_OK;
}
-
-
-
-// END
#include "ail.h"
#include "ail_private.h"
-static void usage(const char *name)
-{
- fprintf(stderr, "\n");
- fprintf(stderr, "Usage: %s\n", name);
- fprintf(stderr, "\n");
-}
-
-ail_cb_ret_e appinfo_list_appid_namefunc(const ail_appinfo_h appinfo, void *user_data)
+ail_cb_ret_e appinfo_list_appid_namefunc(const ail_appinfo_h appinfo, void *user_data, uid_t uid)
{
char *package_str_name = NULL;
char *package_str_appid = NULL;
ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &package_str_name);
ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_EXE_PATH, &package_str_x_slp_exe);
- printf("'%s' '%s' '%s'\n",package_str_appid, package_str_name, package_str_x_slp_exe);
+ printf("'%s' '%s' '%s'\n", package_str_appid, package_str_name, package_str_x_slp_exe);
free(package_str_appid);
free(package_str_name);
int main(int argc, char *argv[])
{
- int o;
- bool err;
-
if (getuid() == 0) {
printf("Please use it as non root user\n");
- return;
+ return -1;
}
printf("Application List for user %lu\n", (long)getuid());
NULL
};
-
static void _print_help(const char *cmd)
{
int i;
fprintf(stderr, "\n");
fprintf(stderr, " <COLUMN NAME>\n");
- for (i = 0; prop_tbl[i]; i++) {
+ for (i = 0; prop_tbl[i]; i++)
fprintf(stderr, " %s\n", prop_tbl[i]);
- }
fprintf(stderr, "\n");
fprintf(stderr, " Ex) %s get com.samsung.menu-screen X_SLP_SERVICE\n", cmd);
fprintf(stderr, "\n");
}
-
-
static int _get_property(const char *property)
{
int i;
- if (!property) {
+ if (!property)
return 0;
- }
for (i = 0; prop_tbl[i]; i++) {
- if (!strcasecmp(prop_tbl[i], property)) {
+ if (!strcasecmp(prop_tbl[i], property))
return i;
- }
}
fprintf(stderr, "%s is not found\n", property);
return -1;
}
-
-
static ail_error_e _get_appinfo(const char *package, const char *property, uid_t uid)
{
ail_appinfo_h handle;
int t;
/* __is admin */
- ret = ail_package_get_appinfo(package, &handle);
+ ret = ail_get_appinfo(package, &handle);
if (ret != AIL_ERROR_OK)
return AIL_ERROR_FAIL;
e.prop = prop;
p = &e;
- ELEMENT_TYPE(p,t);
+ ELEMENT_TYPE(p, t);
if (t == VAL_TYPE_STR) {
ret = ail_appinfo_get_str(handle, property, &str);
END:
free(str);
- ret = ail_package_destroy_appinfo(handle);
+ ret = ail_destroy_appinfo(handle);
if (ret != AIL_ERROR_OK)
return AIL_ERROR_FAIL;
ail_error_e ret = AIL_ERROR_OK;
- if (4 == argc) {
- if (!strncmp(argv[1], "get", 3)) {
+ if (argc == 4) {
+ if (!strncmp(argv[1], "get", 3))
ret = _get_appinfo(argv[2], argv[3], getuid());
- }
- }
- else {
+ } else {
_print_help(argv[0]);
return EXIT_FAILURE;
}
- if (ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK)
fprintf(stderr, "There are some problems\n");
- }
return EXIT_SUCCESS;
}
-
-
*
*/
-
-
+#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <errno.h>
#include <sys/smack.h>
#ifdef _E
#undef _E
#endif
-#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#ifdef _D
#undef _D
#endif
-#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#define SET_DEFAULT_LABEL(x) \
- if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \
- else _D("chsmack -a \"*\" %s", x)
-
-static int createb_count_app(void)
-{
- ail_filter_h filter;
- ail_error_e ret;
- int total = 0;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return -1;
- }
- ret = ail_filter_count_appinfo(filter, &total);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return -1;
- }
-
- ail_filter_destroy(filter);
-
- return total;
-}
-
+ do { \
+ if (smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) \
+ _E("failed chsmack -a \"*\" %s", x); \
+ else \
+ _D("chsmack -a \"*\" %s", x); \
+ } while (0)
static int createdb_change_perm(const char *db_file)
{
- char buf[BUFSZE];
char journal_file[BUFSZE];
char *files[3];
int ret, i;
for (i = 0; files[i]; i++) {
ret = chown(files[i], GLOBAL_USER, OWNER_ROOT);
if (ret == -1) {
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
+ _E("FAIL : chown %s %d.%d, because %d", db_file, OWNER_ROOT, OWNER_ROOT, errno);
return AIL_ERROR_FAIL;
}
ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (ret == -1) {
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chmod %s 0664, because %s", db_file, buf);
+ _E("FAIL : chmod %s 0664, because %d", db_file, errno);
return AIL_ERROR_FAIL;
}
}
}
-static int __is_authorized()
+static int __is_authorized(void)
{
/* ail_init db should be called by as root privilege. */
-
uid_t uid = getuid();
- uid_t euid = geteuid();
- //euid need to be root to allow smack label changes during initialization
+ /* euid need to be root to allow smack label changes during initialization */
+ /* uid_t euid = geteuid(); */
if ((uid_t) OWNER_ROOT == uid)
return 1;
else
if (!__is_authorized()) {
fprintf(stderr, "You are not an authorized user!\n");
_D("You are not root user!\n");
+ } else {
+ if (remove(APP_INFO_DB_FILE))
+ _E(" %s is not removed", APP_INFO_DB_FILE);
+ if (remove(APP_INFO_DB_FILE_JOURNAL))
+ _E(" %s is not removed", APP_INFO_DB_FILE_JOURNAL);
}
- else {
- if(remove(APP_INFO_DB_FILE))
- _E(" %s is not removed",APP_INFO_DB_FILE);
- if(remove(APP_INFO_DB_FILE_JOURNAL))
- _E(" %s is not removed",APP_INFO_DB_FILE_JOURNAL);
- }
+
ret = setenv("AIL_INITDB", "1", 1);
_D("AIL_INITDB : %d", ret);
- setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT);
+
+ if (setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT) != 0)
+ _E("setresuid() is failed");
if (db_open(DB_OPEN_RW, GLOBAL_USER) != AIL_ERROR_OK) {
_E("Fail to create system databases");
return AIL_ERROR_DB_FAILED;
}
- setuid(OWNER_ROOT);
+ if (setuid(OWNER_ROOT) != 0)
+ _E("setuid() is failed.");
+
ret = createdb_change_perm(APP_INFO_DB_FILE);
- if (ret == AIL_ERROR_FAIL) {
+ if (ret == AIL_ERROR_FAIL)
_E("cannot chown.");
- }
+
SET_DEFAULT_LABEL(APP_INFO_DB_FILE);
SET_DEFAULT_LABEL(APP_INFO_DB_FILE_JOURNAL);
return AIL_ERROR_OK;
}
-
-
-
-// END
#ifdef _E
#undef _E
#endif
-
-#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#ifdef _D
#undef _D
#endif
-
-#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#define SET_DEFAULT_LABEL(x) \
do { \
*
*/
-
-
+#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <errno.h>
#include <sys/smack.h>
#include "ail_private.h"
#include "ail_db.h"
-
#ifdef _E
#undef _E
#endif
-#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#ifdef _D
#undef _D
#endif
-#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#define SET_DEFAULT_LABEL(x) \
- if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \
- else _D("chsmack -a \"*\" %s", x)
-
-static int initdb_count_app(void)
-{
- ail_filter_h filter;
- ail_error_e ret;
- int total = 0;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return -1;
- }
- ret = ail_filter_count_appinfo(filter, &total);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return -1;
- }
-
- ail_filter_destroy(filter);
-
- return total;
-}
-
-
-
-char* _desktop_to_package(const char* desktop)
+ do { \
+ if (smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) \
+ _E("failed chsmack -a \"*\" %s", x); \
+ else \
+ _D("chsmack -a \"*\" %s", x); \
+ } while (0)
+
+char *_desktop_to_package(const char* desktop)
{
char *package, *tmp;
retv_if(!package, NULL);
tmp = strrchr(package, '.');
- if(tmp == NULL) {
+ if (tmp == NULL) {
_E("[%s] is not a desktop file", package);
free(package);
return NULL;
return package;
}
-
-
int initdb_load_directory(const char *directory)
{
DIR *dir;
struct dirent entry, *result;
- int len, ret;
+ int ret;
char buf[BUFSZE];
int total_cnt = 0;
int ok_cnt = 0;
- // desktop file
+ /* desktop file */
dir = opendir(directory);
if (!dir) {
if (strerror_r(errno, buf, sizeof(buf)) == 0)
return AIL_ERROR_FAIL;
}
- len = strlen(directory) + 1;
_D("Loading desktop files from %s", directory);
for (ret = readdir_r(dir, &entry, &result);
continue;
}
- if (ail_desktop_add(package) != AIL_ERROR_OK) {
+ if (ail_desktop_add(package) != AIL_ERROR_OK)
_E("Failed to add a package[%s]", package);
- } else {
+ else
ok_cnt++;
- }
+
free(package);
}
return AIL_ERROR_OK;
}
-
-
static int initdb_change_perm(const char *db_file)
{
- char buf[BUFSZE];
char journal_file[BUFSZE];
char *files[3];
int ret, i;
for (i = 0; files[i]; i++) {
ret = chown(files[i], GLOBAL_USER, OWNER_ROOT);
if (ret == -1) {
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
+ _E("FAIL : chown %s %d.%d, because %d", db_file, OWNER_ROOT, OWNER_ROOT, errno);
return AIL_ERROR_FAIL;
}
ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (ret == -1) {
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chmod %s 0664, because %s", db_file, buf);
+ _E("FAIL : chmod %s 0664, because %d", db_file, errno);
return AIL_ERROR_FAIL;
}
}
return AIL_ERROR_OK;
}
-
static int __is_authorized()
{
/* ail_init db should be called by as root privilege. */
-
uid_t uid = getuid();
- uid_t euid = geteuid();
- //euid need to be root to allow smack label changes during initialization
+ /* euid need to be root to allow smack label changes during initialization */
+ /* uid_t euid = geteuid(); */
if ((uid_t) OWNER_ROOT == uid)
return 1;
else
fprintf(stderr, "You are not an authorized user!\n");
_D("You are not root user!\n");
return -1;
- }
- else {
- if(remove(APP_INFO_DB_FILE))
- _E(" %s is not removed",APP_INFO_DB_FILE);
- if(remove(APP_INFO_DB_FILE_JOURNAL))
- _E(" %s is not removed",APP_INFO_DB_FILE_JOURNAL);
+ } else {
+ if (remove(APP_INFO_DB_FILE))
+ _E(" %s is not removed", APP_INFO_DB_FILE);
+ if (remove(APP_INFO_DB_FILE_JOURNAL))
+ _E(" %s is not removed", APP_INFO_DB_FILE_JOURNAL);
}
ret = setenv("AIL_INITDB", "1", 1);
_D("AIL_INITDB : %d", ret);
- setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT);
+
+ if (setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT) != 0)
+ _E("setresuid() is failed.");
if (db_open(DB_OPEN_RW, GLOBAL_USER) != AIL_ERROR_OK) {
_E("Fail to create system databases");
return AIL_ERROR_DB_FAILED;
}
ret = initdb_load_directory(USR_DESKTOP_DIRECTORY);
- if (ret == AIL_ERROR_FAIL) {
+ if (ret == AIL_ERROR_FAIL)
_E("cannot load usr desktop directory.");
- }
- setuid(OWNER_ROOT);
+ if (setuid(OWNER_ROOT) != 0)
+ _E("setuid() is failed.");
+
ret = initdb_change_perm(APP_INFO_DB_FILE);
- if (ret == AIL_ERROR_FAIL) {
+ if (ret == AIL_ERROR_FAIL)
_E("cannot chown.");
- }
+
SET_DEFAULT_LABEL(APP_INFO_DB_FILE);
SET_DEFAULT_LABEL(APP_INFO_DB_FILE_JOURNAL);
return AIL_ERROR_OK;
}
-
-
-
-// END
#ifdef _E
#undef _E
#endif
-#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#ifdef _D
#undef _D
#endif
-#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#define SET_DEFAULT_LABEL(x) \
- if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \
- else _D("chsmack -a \"*\" %s", x)
+ do { \
+ if (smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) \
+ _E("failed chsmack -a \"*\" %s", x); \
+ else \
+ _D("chsmack -a \"*\" %s", x); \
+ } while (0)
static int initdb_user_count_app(void)
{
int total = 0;
ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK)
return -1;
- }
ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
if (ret != AIL_ERROR_OK) {
return total;
}
-
-
-char* _desktop_to_package(const char* desktop)
+char *_desktop_to_package(const char* desktop)
{
char *package, *tmp;
retv_if(!package, NULL);
tmp = strrchr(package, '.');
- if(tmp == NULL) {
+ if (tmp == NULL) {
_E("[%s] is not a desktop file", package);
free(package);
return NULL;
return package;
}
-
-
int initdb_user_load_directory(const char *directory)
{
DIR *dir;
struct dirent entry, *result;
- int len, ret;
+ int ret;
char buf[BUFSZE];
int total_cnt = 0;
int ok_cnt = 0;
- // desktop file
+ /* desktop file */
dir = opendir(directory);
if (!dir) {
if (strerror_r(errno, buf, sizeof(buf)) == 0)
return AIL_ERROR_FAIL;
}
- len = strlen(directory) + 1;
_D("Loading desktop files from %s", directory);
for (ret = readdir_r(dir, &entry, &result);
continue;
}
- if (ail_usr_desktop_add(package, getuid()) != AIL_ERROR_OK) {
+ if (ail_usr_desktop_add(package, getuid()) != AIL_ERROR_OK)
_E("Failed to add a package[%s]", package);
- } else {
+ else
ok_cnt++;
- }
+
free(package);
}
*
*/
-
-
+#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
#include <errno.h>
#include <sys/smack.h>
#ifdef _E
#undef _E
#endif
-#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#ifdef _D
#undef _D
#endif
-#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#define SET_DEFAULT_LABEL(x) \
- if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \
- else _D("chsmack -a \"*\" %s", x)
-
-static int syncdb_count_app(void)
-{
- ail_filter_h filter;
- ail_error_e ret;
- int total = 0;
-
- ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
- return -1;
- }
-
- ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return -1;
- }
- ret = ail_filter_count_appinfo(filter, &total);
- if (ret != AIL_ERROR_OK) {
- ail_filter_destroy(filter);
- return -1;
- }
-
- ail_filter_destroy(filter);
-
- return total;
-}
-
-
+ do { \
+ if (smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) \
+ _E("failed chsmack -a \"*\" %s", x); \
+ else \
+ _D("chsmack -a \"*\" %s", x); \
+ } while (0)
char* _desktop_to_package(const char* desktop)
{
retv_if(!package, NULL);
tmp = strrchr(package, '.');
- if(tmp == NULL) {
+ if (tmp == NULL) {
_E("[%s] is not a desktop file", package);
free(package);
return NULL;
return package;
}
-
-
int syncdb_load_directory(const char *directory)
{
DIR *dir;
struct dirent entry, *result;
- int len, ret;
+ int ret;
char buf[BUFSZE];
int total_cnt = 0;
int ok_cnt = 0;
- // desktop file
+ /* desktop file */
dir = opendir(directory);
if (!dir) {
if (strerror_r(errno, buf, sizeof(buf)) == 0)
return AIL_ERROR_FAIL;
}
- len = strlen(directory) + 1;
_D("Loading desktop files from %s", directory);
for (ret = readdir_r(dir, &entry, &result);
continue;
}
- if (ail_desktop_add(package) != AIL_ERROR_OK) {
+ if (ail_desktop_add(package) != AIL_ERROR_OK)
_E("Failed to add a package[%s]", package);
- } else {
+ else
ok_cnt++;
- }
free(package);
}
return AIL_ERROR_OK;
}
-
-
-static int syncdb_change_perm(const char *db_file)
-{
- char buf[BUFSZE];
- char journal_file[BUFSZE];
- char *files[3];
- int ret, i;
-
- files[0] = (char *)db_file;
- files[1] = journal_file;
- files[2] = NULL;
-
- retv_if(!db_file, AIL_ERROR_FAIL);
-
- snprintf(journal_file, sizeof(journal_file), "%s%s", db_file, "-journal");
-
- for (i = 0; files[i]; i++) {
- ret = chown(files[i], GLOBAL_USER, OWNER_ROOT);
- if (ret == -1) {
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chown %s %d.%d, because %s", db_file, OWNER_ROOT, OWNER_ROOT, buf);
- return AIL_ERROR_FAIL;
- }
-
- ret = chmod(files[i], S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (ret == -1) {
- strerror_r(errno, buf, sizeof(buf));
- _E("FAIL : chmod %s 0664, because %s", db_file, buf);
- return AIL_ERROR_FAIL;
- }
- }
-
- return AIL_ERROR_OK;
-}
-
-
-static int __is_authorized()
+static int __is_authorized(void)
{
/* ail_init db should be called by as root privilege. */
-
uid_t uid = getuid();
- uid_t euid = geteuid();
- //euid need to be root to allow smack label changes during initialization
+ /* euid need to be root to allow smack label changes during initialization */
+ /* uid_t euid = geteuid(); */
if ((uid_t) OWNER_ROOT == uid)
return 1;
else
_D("You are not root user!\n");
return -1;
}
+
if (access(APP_INFO_DB_FILE, F_OK)) {
fprintf(stderr, "Application database %s is missing, please use ail_createdb to create one before\n", APP_INFO_DB_FILE);
return AIL_ERROR_FAIL;
}
+
ret = setenv("AIL_INITDB", "1", 1);
_D("AIL_INITDB : %d", ret);
- setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT);
+
+ if (setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT) != 0)
+ _E("setresuid() is failed.");
if (db_open(DB_OPEN_RW, GLOBAL_USER) != AIL_ERROR_OK) {
_E("Fail to create system databases");
return AIL_ERROR_DB_FAILED;
}
+
ret = syncdb_load_directory(USR_DESKTOP_DIRECTORY);
- if (ret == AIL_ERROR_FAIL) {
+ if (ret == AIL_ERROR_FAIL)
_E("cannot load usr desktop directory.");
- }
return AIL_ERROR_OK;
}
-
-
-
-// END
#ifdef _E
#undef _E
#endif
-#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _E(fmt, arg...) fprintf(stderr, "[AIL_INITDB][E][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#ifdef _D
#undef _D
#endif
-#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg);
+#define _D(fmt, arg...) fprintf(stderr, "[AIL_INITDB][D][%s,%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg)
#define SET_DEFAULT_LABEL(x) \
- if(smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) _E("failed chsmack -a \"*\" %s", x) \
- else _D("chsmack -a \"*\" %s", x)
+ do { \
+ if (smack_setlabel((x), "*", SMACK_LABEL_ACCESS)) \
+ _E("failed chsmack -a \"*\" %s", x); \
+ else \
+ _D("chsmack -a \"*\" %s", x); \
+ } while (0)
static int syncdb_user_count_app(void)
{
int total = 0;
ret = ail_filter_new(&filter);
- if (ret != AIL_ERROR_OK) {
+ if (ret != AIL_ERROR_OK)
return -1;
- }
ret = ail_filter_add_bool(filter, AIL_PROP_NODISPLAY_BOOL, false);
if (ret != AIL_ERROR_OK) {
return total;
}
-char* _desktop_to_package(const char* desktop)
+char *_desktop_to_package(const char* desktop)
{
char *package;
char *tmp;
retv_if(!package, NULL);
tmp = strrchr(package, '.');
- if(tmp == NULL) {
+ if (tmp == NULL) {
_E("[%s] is not a desktop file", package);
free(package);
return NULL;
{
DIR *dir;
struct dirent entry, *result;
- int len, ret;
+ int ret;
char buf[BUFSZE];
int total_cnt = 0;
int ok_cnt = 0;
- /* desktop file */
+ /* desktop file */
dir = opendir(directory);
if (!dir) {
if (strerror_r(errno, buf, sizeof(buf)) == 0)
return AIL_ERROR_FAIL;
}
- len = strlen(directory) + 1;
_D("Loading desktop files from %s", directory);
for (ret = readdir_r(dir, &entry, &result);
ret = readdir_r(dir, &entry, &result)) {
char *package;
- if (entry.d_name[0] == '.') continue;
+ if (entry.d_name[0] == '.')
+ continue;
total_cnt++;
package = _desktop_to_package(entry.d_name);
if (!package) {
continue;
}
- if (ail_usr_desktop_add(package, getuid()) != AIL_ERROR_OK) {
+ if (ail_usr_desktop_add(package, getuid()) != AIL_ERROR_OK)
_E("Failed to add a package[%s]", package);
- } else {
+ else
ok_cnt++;
- }
+
free(package);
}