Fix Prevent and remove compile warning messages 42/51342/5 accepted/tizen/ivi/20160218.023356 accepted/tizen/mobile/20151113.060729 accepted/tizen/tv/20151113.060750 accepted/tizen/wearable/20151113.060758 submit/tizen/20151113.035653 submit/tizen_common/20151229.142028 submit/tizen_common/20151229.144031 submit/tizen_common/20151229.154718 submit/tizen_ivi/20160217.000000 submit/tizen_ivi/20160217.000002
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 9 Nov 2015 01:35:50 +0000 (10:35 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 9 Nov 2015 12:18:48 +0000 (21:18 +0900)
- Read from pointer after free

Change-Id: Iedb925b5a8687e27ba8d2f3d1cbaced220a0c3b6
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
21 files changed:
include/SLP_AIL_PG.h
include/ail.h
src/ail_db.c
src/ail_db.h
src/ail_desktop.c
src/ail_filter.c
src/ail_package.c
src/ail_package.h
src/ail_sql.c
src/ail_vconf.c
tool/src/ail_desktop.c
tool/src/ail_filter.c
tool/src/ail_fota.c
tool/src/ail_list.c
tool/src/ail_package.c
tool/src/createdb.c
tool/src/createdb_user.c
tool/src/initdb.c
tool/src/initdb_user.c
tool/src/syncdb.c
tool/src/syncdb_user.c

index a45be1d..e1d553d 100755 (executable)
  *
  */
 
-
+#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"
@@ -124,56 +125,56 @@ typedef struct ail_appinfo *ail_appinfo_h;
 
 
 <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
@@ -181,90 +182,92 @@ static ail_error_e _remove_desktop(const char *package)
 <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__ */
index e745c61..0f8c871 100755 (executable)
@@ -19,9 +19,6 @@
  *
  */
 
-
-
-
 #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
@@ -85,8 +80,8 @@ extern "C" {
 #define        AIL_PROP_X_SLP_APPID_STR                "AIL_PROP_X_SLP_APPID_STR"
 #define        AIL_PROP_X_SLP_PKGID_STR                "AIL_PROP_X_SLP_PKGID_STR"
 #define        AIL_PROP_X_SLP_DOMAIN_STR               "AIL_PROP_X_SLP_DOMAIN_STR"
-#define        AIL_PROP_X_SLP_SUBMODEMAINID_STR                "AIL_PROP_X_SLP_SUBMODEMAINID_STR"
-#define        AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR             "AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR"
+#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
@@ -116,15 +111,15 @@ typedef struct ail_filter *ail_filter_h;
 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;
 
 /**
@@ -150,43 +145,37 @@ typedef enum {
  * 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)
  *
@@ -195,8 +184,8 @@ ail_error_e ail_filter_new(ail_filter_h *filter);
  * @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
@@ -211,31 +200,28 @@ ail_error_e ail_filter_new(ail_filter_h *filter);
  * 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);
@@ -265,37 +251,32 @@ ail_error_e ail_filter_add_int(ail_filter_h filter, const char *property, const
  * 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)
  *
@@ -308,7 +289,7 @@ ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, bool
  * @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
  *
@@ -319,38 +300,34 @@ ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *property, bool
  * @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)
  *
@@ -361,8 +338,8 @@ ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const
  * @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()
  *
@@ -372,51 +349,44 @@ ail_error_e ail_filter_add_str(ail_filter_h filter, const char *property, const
  * 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
  */
@@ -434,12 +404,12 @@ typedef enum {
  * @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)
@@ -449,14 +419,14 @@ typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void
  * @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()
@@ -467,57 +437,51 @@ typedef ail_cb_ret_e (*ail_list_appinfo_cb) (const ail_appinfo_h appinfo_h, void
  * 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)
@@ -526,13 +490,13 @@ ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
  * @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
@@ -546,38 +510,34 @@ ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
  * 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);
@@ -586,23 +546,22 @@ ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count, uid_t
 /**
  * @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.
@@ -613,53 +572,52 @@ ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *count, uid_t
  * 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.
@@ -670,30 +628,28 @@ ail_error_e ail_package_get_usr_appinfo(const char *package, uid_t uid, ail_appi
  * 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);
@@ -702,9 +658,9 @@ ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *han
 /**
  * @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.
  *
@@ -713,9 +669,9 @@ ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *han
  * @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.
@@ -726,42 +682,38 @@ ail_error_e ail_get_usr_appinfo(const char *appid, uid_t uid, ail_appinfo_h *han
  * 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.
  *
@@ -770,8 +722,8 @@ ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *propert
  * @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.
@@ -783,30 +735,28 @@ ail_error_e ail_appinfo_get_bool(const ail_appinfo_h handle, const char *propert
  * 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);
@@ -814,9 +764,9 @@ ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property
 /**
  * @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.
  *
@@ -826,8 +776,8 @@ ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property
  * @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.
@@ -839,36 +789,33 @@ ail_error_e ail_appinfo_get_int(const ail_appinfo_h handle, const char *property
  * 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)
  *
@@ -879,8 +826,8 @@ ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h handle, const char *prop
  * @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.
@@ -892,35 +839,32 @@ ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h handle, const char *prop
  * 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)
  *
@@ -931,8 +875,8 @@ ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle) __attribute_
  * @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.
@@ -944,30 +888,28 @@ ail_error_e ail_package_destroy_appinfo(const ail_appinfo_h handle) __attribute_
  * 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);
@@ -980,8 +922,8 @@ 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.
@@ -993,48 +935,44 @@ ail_error_e ail_destroy_appinfo(const ail_appinfo_h handle);
  * 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.
  *
@@ -1042,9 +980,9 @@ ail_error_e ail_close_appinfo_db(void);
  * @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.
@@ -1055,43 +993,40 @@ ail_error_e ail_close_appinfo_db(void);
  * 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.
@@ -1102,32 +1037,29 @@ ail_error_e ail_usr_desktop_add(const char *appid, uid_t uid);
  * 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.
  *
@@ -1135,9 +1067,9 @@ ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid);
  * @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.
@@ -1148,21 +1080,19 @@ ail_error_e ail_usr_desktop_update(const char *appid, uid_t uid);
  * 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);
@@ -1176,12 +1106,12 @@ ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid);
  * @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.
@@ -1192,21 +1122,19 @@ ail_error_e ail_usr_desktop_remove(const char *appid, uid_t uid);
  * 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);
@@ -1216,10 +1144,10 @@ ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid);
  * @fn ail_error_e ail_desktop_fota(const char *appid)
  * @fn ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid)
  * @brief add a app information into Application Information Database.
      A desktop file for this app has to be installed in the desktop directory before using this API.
      If there is no database for Application Information Database, this API will create the DB.
      If there is a DB, this function adds information for the app into the DB.
      And a notification is not published to the applications who want to know about changing DB.
*     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.
  *
@@ -1227,9 +1155,9 @@ ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid);
  * @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.
@@ -1240,40 +1168,39 @@ ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid);
  * 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.
@@ -1283,38 +1210,33 @@ ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid);
  * 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
index 4819088..e96ef86 100755 (executable)
@@ -19,9 +19,8 @@
  *
  */
 
-
-
-
+#define _GNU_SOURCE
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <db-util.h>
@@ -42,7 +41,7 @@
 
 #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); \
@@ -82,9 +81,9 @@
 
 static __thread struct {
        sqlite3 *dbUserro;
-        sqlite3 *dbGlobalro;
-        sqlite3 *dbUserrw;
-        sqlite3 *dbGlobalrw;
+       sqlite3 *dbGlobalro;
+       sqlite3 *dbUserrw;
+       sqlite3 *dbGlobalrw;
 } db_info = {
        .dbUserro = NULL,
        .dbGlobalro = NULL,
@@ -96,7 +95,6 @@ static __thread sqlite3 *dbInit = 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;
@@ -134,18 +132,16 @@ static int ail_db_change_perm(const char *db_file, uid_t uid)
        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;
                }
@@ -161,7 +157,6 @@ char *ail_get_icon_path(uid_t uid)
        char *result = NULL;
        struct group grpbuf;
        struct group *grpinfo = NULL;
-       char *dir = NULL;
        struct passwd pwd;
        struct passwd *userinfo = NULL;
        int buflen;
@@ -216,7 +211,9 @@ char *ail_get_icon_path(uid_t uid)
                        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, "/"));
@@ -233,10 +230,8 @@ char *ail_get_icon_path(uid_t uid)
                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);
                }
        }
 
@@ -250,7 +245,9 @@ char *ail_get_app_DB_journal(uid_t uid)
        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;
@@ -317,7 +314,9 @@ char *ail_get_app_DB(uid_t uid)
                        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);
@@ -346,12 +345,10 @@ char *ail_get_app_DB(uid_t uid)
                _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);
                }
        }
 
@@ -366,7 +363,6 @@ char *ail_get_desktop_path(uid_t uid)
        char *result = NULL;
        struct group grpbuf;
        struct group *grpinfo = NULL;
-       char *dir = NULL;
        struct passwd pwd;
        struct passwd *userinfo = NULL;
        int buflen;
@@ -421,7 +417,9 @@ char *ail_get_desktop_path(uid_t uid)
                        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, "/"));
@@ -436,12 +434,10 @@ char *ail_get_desktop_path(uid_t uid)
                _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);
                }
        }
 
@@ -470,7 +466,6 @@ static ail_error_e db_do_prepare(sqlite3 *db, const char *query, sqlite3_stmt **
 ail_error_e db_open(db_open_mode mode, uid_t uid)
 {
        int ret;
-       int changed = 0;
        int i;
        char *db;
        char *global_db;
@@ -528,16 +523,15 @@ ail_error_e db_open(db_open_mode mode, uid_t uid)
        }
 
        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);
@@ -549,8 +543,8 @@ ail_error_e db_open(db_open_mode mode, uid_t uid)
                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];
@@ -651,7 +645,7 @@ ail_error_e db_bind_int(sqlite3_stmt *stmt, int idx, int value)
        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;
 
@@ -671,10 +665,10 @@ ail_error_e db_step(sqlite3_stmt *stmt)
 
        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);
@@ -688,7 +682,7 @@ ail_error_e db_column_bool(sqlite3_stmt *stmt, int index, bool *value)
        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;
 }
@@ -750,8 +744,8 @@ ail_error_e do_db_exec(const char *query, sqlite3 * fileSQL)
        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;
        }
@@ -783,22 +777,21 @@ ail_error_e db_close(void)
 {
        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;
        }
 
@@ -813,7 +806,7 @@ EXPORT_API ail_error_e ail_db_close(void)
 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,
@@ -822,7 +815,7 @@ int db_exec_sqlite_query(char *query, sqlite_query_callback callback, void *data
                        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,
index dc40c68..9e044a8 100755 (executable)
@@ -19,9 +19,6 @@
  *
  */
 
-
-
-
 #ifndef __AIL_DB_H__
 #define __AIL_DB_H__
 
@@ -48,7 +45,7 @@ ail_error_e db_prepare_globalrw(const char *query, sqlite3_stmt **stmt);
 
 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);
 
@@ -59,10 +56,11 @@ ail_error_e db_column_str(sqlite3_stmt *stmt, int index, char **str);
 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__ */
index b2a9bf1..15e4fa4 100755 (executable)
@@ -42,6 +42,7 @@
 #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)
@@ -55,7 +56,7 @@
 #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,
@@ -69,23 +70,24 @@ struct entry_parser {
        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;
 }
@@ -129,8 +131,6 @@ typedef struct {
        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;
@@ -145,7 +145,7 @@ static ail_error_e _read_exec(void *data, char *tag, char *value, uid_t uid)
        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;
        }
@@ -153,7 +153,7 @@ static ail_error_e _read_exec(void *data, char *tag, char *value, uid_t uid)
        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);
@@ -165,8 +165,6 @@ static ail_error_e _read_exec(void *data, char *tag, char *value, uid_t uid)
        return AIL_ERROR_OK;
 }
 
-
-
 static ail_error_e _read_name(void *data, char *tag, char *value, uid_t uid)
 {
        desktop_info_s *info = data;
@@ -178,17 +176,17 @@ static ail_error_e _read_name(void *data, char *tag, char *value, uid_t uid)
        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);
@@ -200,14 +198,12 @@ static ail_error_e _read_name(void *data, char *tag, char *value, uid_t uid)
                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;
@@ -216,33 +212,29 @@ static ail_error_e _read_type(void *data, char *tag, char *value, uid_t uid)
        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)
 {
-       charpackage;
-       charextension;
+       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)
 {
@@ -253,22 +245,12 @@ _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");
@@ -276,11 +258,9 @@ _get_icon_with_path(char* icon, uid_t uid)
                        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);
@@ -288,16 +268,17 @@ _get_icon_with_path(char* icon, uid_t uid)
                }
 
                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);
@@ -313,7 +294,6 @@ _get_icon_with_path(char* icon, uid_t uid)
        }
 }
 
-
 static ail_error_e _read_icon(void *data, char *tag, char *value, uid_t uid)
 {
        desktop_info_s *info = data;
@@ -323,13 +303,11 @@ static ail_error_e _read_icon(void *data, char *tag, char *value, uid_t uid)
 
        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;
@@ -338,13 +316,11 @@ static ail_error_e _read_categories(void *data, char *tag, char *value, uid_t ui
        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;
@@ -353,13 +329,11 @@ static ail_error_e _read_version(void *data, char *tag, char *value, uid_t uid)
        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;
@@ -375,7 +349,7 @@ static ail_error_e _read_mimetype(void *data, char *tag, char *value, uid_t uid)
 
        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;
@@ -398,7 +372,7 @@ static ail_error_e _read_mimetype(void *data, char *tag, char *value, uid_t uid)
                        char *tmp;
                        size *= 2;
                        tmp = realloc(mimes_changed, size);
-                       if(!tmp) {
+                       if (!tmp) {
                                free(mimes_changed);
                                return AIL_ERROR_OUT_OF_MEMORY;
                        }
@@ -409,9 +383,8 @@ static ail_error_e _read_mimetype(void *data, char *tag, char *value, uid_t uid)
                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);
@@ -420,8 +393,6 @@ static ail_error_e _read_mimetype(void *data, char *tag, char *value, uid_t uid)
        return AIL_ERROR_OK;
 }
 
-
-
 static ail_error_e _read_nodisplay(void *data, char *tag, char *value, uid_t uid)
 {
        desktop_info_s* info = data;
@@ -765,27 +736,6 @@ static struct entry_parser entry_parsers[] = {
        },
 };
 
-
-
-/* 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;
@@ -818,18 +768,19 @@ char *_pkgname_to_desktop(const char *package, uid_t uid)
 
 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);
@@ -837,6 +788,7 @@ static inline int _bind_local_info(desktop_info_s* info, sqlite3_stmt * stmt)
                }
                localname = g_slist_next(localname);
        }
+
        return AIL_ERROR_OK;
 }
 
@@ -846,12 +798,12 @@ static inline int _len_local_info(desktop_info_s* info)
        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);
                }
        }
@@ -893,7 +845,7 @@ static inline int _insert_local_info(desktop_info_s* info, uid_t uid)
 
                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;
                }
@@ -902,7 +854,7 @@ static inline int _insert_local_info(desktop_info_s* info, uid_t uid)
                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;
                }
@@ -944,10 +896,9 @@ static inline int _strlen_desktop_info(desktop_info_s* info)
        return len;
 }
 
-
 int __is_ail_initdb(void)
 {
-       if( getenv("AIL_INITDB") || getenv("INITDB") )
+       if (getenv("AIL_INITDB") || getenv("INITDB"))
                return 1;
        else
                return 0;
@@ -1001,7 +952,7 @@ static ail_error_e _init_desktop_info(desktop_info_s *info, const char *package,
        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;
@@ -1018,9 +969,12 @@ static ail_error_e _read_desktop_info(desktop_info_s* info,uid_t uid)
                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);
@@ -1028,9 +982,8 @@ static ail_error_e _read_desktop_info(desktop_info_s* info,uid_t uid)
                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);
@@ -1038,15 +991,13 @@ static ail_error_e _read_desktop_info(desktop_info_s* info,uid_t uid)
 
                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;
                        }
                }
@@ -1150,19 +1101,20 @@ static ail_error_e _load_desktop_info(desktop_info_s* info, uid_t uid)
                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) {
@@ -1177,10 +1129,11 @@ static ail_error_e _load_desktop_info(desktop_info_s* info, uid_t uid)
                }
 
                ret = db_finalize(stmt);
-               if (ret < 0) break;
+               if (ret < 0)
+                       break;
 
                return AIL_ERROR_OK;
-       } while(0);
+       } while (0);
 
        return ret;
 }
@@ -1190,7 +1143,6 @@ static ail_error_e _modify_desktop_info_bool(desktop_info_s* info,
                                                  bool value)
 {
        ail_prop_bool_e prop;
-       int val;
 
        retv_if(!info, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!property, AIL_ERROR_INVALID_PARAMETER);
@@ -1201,11 +1153,11 @@ static ail_error_e _modify_desktop_info_bool(desktop_info_s* info,
                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;
@@ -1216,8 +1168,7 @@ static ail_error_e _modify_desktop_info_str(desktop_info_s* info,
                                                  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);
@@ -1228,21 +1179,21 @@ static ail_error_e _modify_desktop_info_str(desktop_info_s* info,
                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;
@@ -1259,12 +1210,12 @@ static inline void _insert_localname(gpointer data, gpointer user_data, uid_t ui
        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);
        }
 }
 
@@ -1349,7 +1300,7 @@ static ail_error_e _insert_desktop_info(desktop_info_s *info, uid_t uid)
                );
 
        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;
@@ -1375,17 +1326,16 @@ static ail_error_e _update_desktop_info(desktop_info_s *info, uid_t uid)
        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', "
@@ -1447,26 +1397,26 @@ static ail_error_e _update_desktop_info(desktop_info_s *info, uid_t uid)
                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;
                }
        }
@@ -1489,9 +1439,8 @@ static ail_error_e _remove_package(const char* package, uid_t uid)
 
        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);
@@ -1499,7 +1448,7 @@ static ail_error_e _remove_package(const char* package, uid_t uid)
 
        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;
@@ -1511,9 +1460,9 @@ static ail_error_e _remove_package(const char* package, uid_t uid)
                }
        }
        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;
@@ -1537,9 +1486,8 @@ static ail_error_e _clean_pkgid_data(const char* pkgid, uid_t uid)
 
        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);
@@ -1547,7 +1495,7 @@ static ail_error_e _clean_pkgid_data(const char* pkgid, uid_t uid)
 
        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;
@@ -1559,9 +1507,9 @@ static ail_error_e _clean_pkgid_data(const char* pkgid, uid_t uid)
                }
        }
        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;
@@ -1586,17 +1534,17 @@ static ail_error_e _send_db_done_noti(noti_type type, const char *package)
        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());
@@ -1611,11 +1559,10 @@ static ail_error_e _send_db_done_noti(noti_type type, const char *package)
        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);
@@ -1654,15 +1601,6 @@ static void _fini_desktop_info(desktop_info_s *info)
        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)
 {
@@ -1725,10 +1663,9 @@ end:
 
 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;
@@ -1756,7 +1693,7 @@ EXPORT_API ail_error_e ail_usr_desktop_clean(const char *pkgid, uid_t uid)
 
        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);
@@ -1780,7 +1717,7 @@ EXPORT_API ail_error_e ail_usr_desktop_fota(const char *appid, uid_t uid)
        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;
 
index 096b28a..82ec431 100755 (executable)
@@ -47,10 +47,10 @@ EXPORT_API ail_error_e ail_filter_new(ail_filter_h *filter)
 {
        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;
 
@@ -68,7 +68,7 @@ static inline void _destroy_cond(gpointer data, gpointer user_data)
        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);
@@ -78,9 +78,9 @@ static inline void _destroy_cond(gpointer data, gpointer user_data)
 
 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);
        }
@@ -96,8 +96,8 @@ EXPORT_API ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *prop
        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);
 
@@ -105,7 +105,7 @@ EXPORT_API ail_error_e ail_filter_add_bool(ail_filter_h filter, const char *prop
                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;
@@ -120,8 +120,8 @@ EXPORT_API ail_error_e ail_filter_add_int(ail_filter_h filter, const char *prope
        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);
 
@@ -129,7 +129,7 @@ EXPORT_API ail_error_e ail_filter_add_int(ail_filter_h filter, const char *prope
                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;
@@ -141,23 +141,22 @@ EXPORT_API ail_error_e ail_filter_add_int(ail_filter_h filter, const char *prope
 
 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);
@@ -185,23 +184,22 @@ static void _get_condition(gpointer data, char **condition)
        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);
@@ -221,24 +219,26 @@ char *_get_where_clause(ail_filter_h filter)
 
        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);
 }
 
@@ -248,7 +248,6 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
        char *w;
        char *tmp_q;
        char *l;
-       ail_cb_ret_e r;
        sqlite3_stmt *stmt;
        ail_appinfo_h ai;
        int filter_count = 0;
@@ -261,9 +260,9 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *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) {
+       if (l == NULL) {
                _E("Failed to get locale string");
                free(tmp_q);
                return AIL_ERROR_FAIL;
@@ -274,17 +273,17 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
 
        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();
@@ -297,7 +296,7 @@ EXPORT_API ail_error_e ail_filter_count_appinfo(ail_filter_h filter, int *cnt)
        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++;
@@ -317,14 +316,13 @@ EXPORT_API ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *cn
        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);
 
@@ -334,7 +332,7 @@ EXPORT_API ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *cn
        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");
@@ -347,16 +345,16 @@ EXPORT_API ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *cn
 
        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;
        }
 
@@ -369,8 +367,7 @@ EXPORT_API ail_error_e ail_filter_count_usr_appinfo(ail_filter_h filter, int *cn
 
        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++;
@@ -395,7 +392,7 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
        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;
@@ -403,9 +400,9 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
        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;
@@ -416,23 +413,22 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
 
        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;
        }*/
@@ -445,12 +441,12 @@ EXPORT_API ail_error_e ail_filter_list_appinfo_foreach(ail_filter_h filter, ail_
 
        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;
        }
@@ -470,7 +466,7 @@ EXPORT_API ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
        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;
@@ -478,9 +474,9 @@ EXPORT_API ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
        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;
@@ -491,19 +487,19 @@ EXPORT_API ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
 
        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;
        }
 
@@ -516,11 +512,11 @@ EXPORT_API ail_error_e ail_filter_list_usr_appinfo_foreach(ail_filter_h filter,
 
        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;
        }
index 6657e61..7b67dec 100755 (executable)
 
 #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"
@@ -50,7 +52,6 @@ typedef struct _pkgmgr_locale_x {
        char *locale;
 } pkgmgr_locale_x;
 
-
 /* get the first locale value*/
 static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **colname)
 {
@@ -66,7 +67,7 @@ static int __fallback_locale_cb(void *data, int ncols, char **coltxt, char **col
 
 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;
 }
@@ -85,7 +86,7 @@ static int __check_app_locale_from_app_localized_info_by_exact(const char *appid
 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);
@@ -98,7 +99,7 @@ static int __check_app_locale_from_app_localized_info_by_fallback(const char *ap
 
 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;
@@ -109,7 +110,7 @@ static char* __get_app_locale_from_app_localized_info_by_fallback(const char *ap
                _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);
@@ -120,7 +121,7 @@ static char* __get_app_locale_from_app_localized_info_by_fallback(const char *ap
        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) {
@@ -154,7 +155,7 @@ static char* __get_app_locale_by_fallback(const char *appid, const char *sysloca
 
        /* 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);
@@ -183,7 +184,7 @@ static ail_error_e __retrieve_all_column(ail_appinfo_h ai)
 
        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) {
@@ -222,15 +223,13 @@ int _appinfo_check_installed_storage(ail_appinfo_h ai)
        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];
@@ -243,7 +242,7 @@ int _appinfo_check_installed_storage(ail_appinfo_h ai)
                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; */
                }
        }
 
@@ -259,7 +258,7 @@ ail_appinfo_h appinfo_create(void)
 {
        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;
@@ -284,9 +283,8 @@ EXPORT_API ail_error_e ail_destroy_appinfo(ail_appinfo_h 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);
@@ -463,7 +461,7 @@ EXPORT_API ail_error_e ail_appinfo_get_bool(const ail_appinfo_h ai, const char *
                        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;
 }
@@ -503,9 +501,9 @@ char *appinfo_get_localname(const char *package, char *locale, uid_t uid)
        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)
@@ -520,7 +518,7 @@ char *appinfo_get_localname(const char *package, char *locale, uid_t uid)
                db_finalize(stmt);
 
                return localname;
-       } while(0);
+       } while (0);
 
        db_finalize(stmt);
        return NULL;
@@ -551,16 +549,15 @@ EXPORT_API ail_error_e ail_appinfo_get_str(const ail_appinfo_h ai, const char *p
                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;
                                }
@@ -576,13 +573,12 @@ EXPORT_API ail_error_e ail_appinfo_get_str(const ail_appinfo_h ai, const char *p
                } 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);
@@ -608,15 +604,16 @@ EXPORT_API ail_error_e ail_appinfo_get_str(const ail_appinfo_h ai, const char *p
 
        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;
@@ -642,16 +639,15 @@ EXPORT_API ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h ai, const cha
                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;
                                }
@@ -667,13 +663,12 @@ EXPORT_API ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h ai, const cha
                } 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);
@@ -699,9 +694,9 @@ EXPORT_API ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h ai, const cha
 
        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];
@@ -709,10 +704,7 @@ EXPORT_API ail_error_e ail_appinfo_get_usr_str(const ail_appinfo_h ai, const cha
        return AIL_ERROR_OK;
 }
 
-
 EXPORT_API ail_error_e ail_close_appinfo_db(void)
 {
        return db_close();
 }
-
-// End of file
index 9270334..c4326c8 100755 (executable)
@@ -31,5 +31,6 @@
 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__ */
index 708eccc..febe8de 100755 (executable)
@@ -63,7 +63,6 @@ static const char *filter[] = {
        NULL,
 };
 
-
 inline const char *sql_get_filter(int prop)
 {
        retv_if(prop < 0 || prop >= NUM_OF_PROP , NULL);
@@ -77,7 +76,7 @@ inline char *sql_get_locale(void)
        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);
 
@@ -90,5 +89,3 @@ inline int sql_get_app_info_idx(int prop)
 {
        return prop;
 }
-
-// End of file
index a1471c3..27bb366 100644 (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;
@@ -50,7 +48,7 @@ static char *_pread_(FILE *stream, size_t block_size)
        size_t length = 0;
        char *string;
 
-       for(;;) {
+       for (;;) {
                /* is on error ? */
                if (ferror(stream) != 0) {
                        free(result);
@@ -79,13 +77,11 @@ static char *_pread_(FILE *stream, size_t block_size)
 }
 
 /*
- 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;
@@ -102,9 +98,8 @@ static int _ail_vconf_exec_(char **readen, const char *cmddef, ...)
                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);
        }
@@ -112,8 +107,8 @@ static int _ail_vconf_exec_(char **readen, const char *cmddef, ...)
 }
 
 /*
- 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;
@@ -132,9 +127,8 @@ EXPORT_API char *ail_vconf_get_str(const char *keyname)
                                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);
                        }
@@ -145,8 +139,8 @@ EXPORT_API char *ail_vconf_get_str(const char *keyname)
 }
 
 /*
- 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;
@@ -161,6 +155,3 @@ EXPORT_API int ail_vconf_set_str(const char *keyname, const char *strval)
 }
 
 #endif
-
-
-
index 0140d20..4dcfde2 100644 (file)
@@ -29,7 +29,6 @@
 
 #include <ail.h>
 
-
 static void _print_help(const char *cmd)
 {
        fprintf(stderr, "Usage:\n");
@@ -51,86 +50,68 @@ static void _print_help(const char *cmd)
        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;
 }
-
index b6ecaf6..38717fa 100644 (file)
@@ -71,20 +71,20 @@ struct _ail_map_t {
 };
 
 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},
@@ -107,28 +107,25 @@ static struct _ail_map_t prop_map[] = {
 
 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;
@@ -150,52 +147,54 @@ static int _get_cmd(const char *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;
@@ -253,63 +252,59 @@ int main(int argc, char *argv[])
                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;
                }
        }
 
index 20d17c5..c240279 100644 (file)
@@ -27,6 +27,8 @@
 #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)
 {
@@ -54,20 +60,20 @@ 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;
@@ -78,11 +84,10 @@ static int initdb_count_app(uid_t uid)
        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);
 
@@ -90,7 +95,7 @@ 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;
@@ -113,12 +118,12 @@ 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)
@@ -126,7 +131,6 @@ int initdb_load_directory(const char *directory)
                return AIL_ERROR_FAIL;
        }
 
-       len = strlen(directory) + 1;
        _D("Loading desktop files from %s", directory);
 
        for (ret = readdir_r(dir, &entry, &result);
@@ -142,11 +146,10 @@ int initdb_load_directory(const char *directory)
                        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);
        }
 
@@ -199,8 +202,8 @@ static int __is_authorized()
 
        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;
@@ -246,37 +249,31 @@ int main(int argc, char *argv[])
        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
index 8304a26..44765b3 100644 (file)
 #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;
@@ -42,7 +35,7 @@ ail_cb_ret_e appinfo_list_appid_namefunc(const ail_appinfo_h appinfo, void *user
        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);
@@ -53,12 +46,9 @@ ail_cb_ret_e appinfo_list_appid_namefunc(const ail_appinfo_h appinfo, void *user
 
 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());
index fd3a490..d69920f 100644 (file)
@@ -58,7 +58,6 @@ char *prop_tbl[] = {
        NULL
 };
 
-
 static void _print_help(const char *cmd)
 {
        int i;
@@ -70,29 +69,24 @@ static void _print_help(const char *cmd)
        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);
@@ -100,8 +94,6 @@ static int _get_property(const char *property)
        return -1;
 }
 
-
-
 static ail_error_e _get_appinfo(const char *package, const char *property, uid_t uid)
 {
        ail_appinfo_h handle;
@@ -114,7 +106,7 @@ static ail_error_e _get_appinfo(const char *package, const char *property, uid_t
        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;
 
@@ -124,7 +116,7 @@ static ail_error_e _get_appinfo(const char *package, const char *property, uid_t
 
        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);
@@ -149,7 +141,7 @@ static ail_error_e _get_appinfo(const char *package, const char *property, uid_t
 END:
        free(str);
 
-       ret = ail_package_destroy_appinfo(handle);
+       ret = ail_destroy_appinfo(handle);
        if (ret != AIL_ERROR_OK)
                return AIL_ERROR_FAIL;
 
@@ -161,21 +153,16 @@ int main(int argc, char** argv)
        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;
 }
-
-
index e612505..04f3f70 100644 (file)
  *
  */
 
-
-
+#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;
@@ -97,15 +73,13 @@ static int createdb_change_perm(const char *db_file)
        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;
                }
        }
@@ -114,13 +88,12 @@ static int createdb_change_perm(const char *db_file)
 }
 
 
-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
@@ -167,33 +140,33 @@ int main(int argc, char *argv[])
        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
index daa06c7..a9474df 100644 (file)
 #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 { \
index 75d5788..1df643e 100755 (executable)
  *
  */
 
-
-
+#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;
 
@@ -88,7 +63,7 @@ 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;
@@ -105,18 +80,16 @@ char* _desktop_to_package(const char* desktop)
        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)
@@ -124,7 +97,6 @@ int initdb_load_directory(const char *directory)
                return AIL_ERROR_FAIL;
        }
 
-       len = strlen(directory) + 1;
        _D("Loading desktop files from %s", directory);
 
        for (ret = readdir_r(dir, &entry, &result);
@@ -140,11 +112,11 @@ int initdb_load_directory(const char *directory)
                        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);
        }
 
@@ -154,11 +126,8 @@ int initdb_load_directory(const char *directory)
        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;
@@ -174,15 +143,13 @@ static int initdb_change_perm(const char *db_file)
        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;
                }
        }
@@ -190,14 +157,12 @@ static int initdb_change_perm(const char *db_file)
        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
@@ -245,37 +210,35 @@ int main(int argc, char *argv[])
                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
index 4aae135..5de4b8c 100755 (executable)
 #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)
 {
@@ -55,9 +59,8 @@ 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) {
@@ -75,9 +78,7 @@ static int initdb_user_count_app(void)
        return total;
 }
 
-
-
-char* _desktop_to_package(const char* desktop)
+char *_desktop_to_package(const char* desktop)
 {
        char *package, *tmp;
 
@@ -87,7 +88,7 @@ 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;
@@ -104,18 +105,16 @@ char* _desktop_to_package(const char* desktop)
        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)
@@ -123,7 +122,6 @@ int initdb_user_load_directory(const char *directory)
                return AIL_ERROR_FAIL;
        }
 
-       len = strlen(directory) + 1;
        _D("Loading desktop files from %s", directory);
 
        for (ret = readdir_r(dir, &entry, &result);
@@ -139,11 +137,11 @@ int initdb_user_load_directory(const char *directory)
                        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);
        }
 
index 247602b..231de08 100644 (file)
  *
  */
 
-
-
+#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)
 {
@@ -90,7 +66,7 @@ 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;
@@ -107,18 +83,16 @@ char* _desktop_to_package(const char* desktop)
        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)
@@ -126,7 +100,6 @@ int syncdb_load_directory(const char *directory)
                return AIL_ERROR_FAIL;
        }
 
-       len = strlen(directory) + 1;
        _D("Loading desktop files from %s", directory);
 
        for (ret = readdir_r(dir, &entry, &result);
@@ -142,11 +115,10 @@ int syncdb_load_directory(const char *directory)
                        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);
        }
 
@@ -156,50 +128,12 @@ int syncdb_load_directory(const char *directory)
        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
@@ -248,26 +182,26 @@ int main(int argc, char *argv[])
                _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
index 23efdc8..1038a0d 100644 (file)
 #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)
 {
@@ -55,9 +59,8 @@ 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) {
@@ -75,7 +78,7 @@ static int syncdb_user_count_app(void)
        return total;
 }
 
-char_desktop_to_package(const char* desktop)
+char *_desktop_to_package(const char* desktop)
 {
        char *package;
        char *tmp;
@@ -86,7 +89,7 @@ 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;
@@ -109,12 +112,12 @@ int syncdb_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)
@@ -122,7 +125,6 @@ int syncdb_user_load_directory(const char *directory)
                return AIL_ERROR_FAIL;
        }
 
-       len = strlen(directory) + 1;
        _D("Loading desktop files from %s", directory);
 
        for (ret = readdir_r(dir, &entry, &result);
@@ -130,7 +132,8 @@ int syncdb_user_load_directory(const char *directory)
                        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) {
@@ -138,11 +141,11 @@ int syncdb_user_load_directory(const char *directory)
                        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);
        }