INSTALL(FILES ${CMAKE_SOURCE_DIR}/desktop.conf DESTINATION share/install-info)
# AIL init database
-ADD_SUBDIRECTORY(initdb)
-
+ADD_SUBDIRECTORY(tool)
#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"
/**
* @brief integer type properties
#define AIL_PROP_X_SLP_REMOVABLE_BOOL "AIL_PROP_X_SLP_REMOVABLE_BOOL"
#define AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL "AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL"
#define AIL_PROP_X_SLP_ENABLED_BOOL "AIL_PROP_X_SLP_ENABLED_BOOL"
-
+#define AIL_PROP_X_SLP_SUBMODE_BOOL "AIL_PROP_X_SLP_SUBMODE_BOOL"
/**
* @brief A handle for filters
*/
ail_error_e ail_desktop_clean(const char *pkgid);
+
+/**
+ * @fn ail_error_e ail_desktop_fota(const char *appid)
+ *
+ * @brief add a app information into Application Information Database.
+ A desktop file for this app has to be installed in the desktop directory before using this API.
+ If there is no database for Application Information Database, this API will create the DB.
+ If there is a DB, this function adds information for the app into the DB.
+ And a notification is not published to the applications who want to know about changing DB.
+ *
+ * @par Sync (or) Async : Synchronous API.
+ *
+ * @param[in] appid
+ *
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AIL_ERROR_OK success
+ * @retval AIL_ERROR_FAIL internal error
+ * @retval AIL_ERROR_INVALID_PARAMETER invalid parameter
+ *
+ * @pre a desktop file for the app has to be installed in the desktop directory before using this API.
+ * @post app information is added into the Application Information Database.
+ *
+ * @see ail_desktop_update(), ail_desktop_remove()
+ *
+ * @par Prospective Clients:
+ * External Apps.
+ *
+ * @code
+static ail_error_e _add_desktop_fota(const char *appid)
+{
+ ail_error_e ret;
+
+ if (!appid) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_fota(appid);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+ * @endcode
+ */
+ail_error_e ail_desktop_fota(const char *appid);
+
/**
* @fn ail_error_e ail_desktop_appinfo_modify_str(const char *appid, const char *property, const char *value, bool broadcast)
*
#sbs-git:slp/pkgs/a/ail ail 0.2.22 29ac1f2c98453cad647cca6a92abc7da3dbb047b
Name: ail
Summary: Application Information Library
-Version: 0.2.75
+Version: 0.2.79
Release: 1
Group: System/Libraries
License: Apache License, Version 2.0
%build
CFLAGS+=" -fpic"
+
+%if 0%{?tizen_build_binary_release_type_eng}
+export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
+export CXXFLAGS="$CXXFLAGS ?DTIZEN_ENGINEER_MODE"
+export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
+%endif
+
%cmake . -DBUILD_PKGTYPE=rpm
make %{?jobs:-j%jobs}
echo "Failed to change the perms of $@"
fi
}
+mkdir -p /usr/share/applications
+mkdir -p /opt/share/applications
mkdir -p /opt/dbspace/
-ail_initdb
+
update_DAC_for_db_file /opt/dbspace/.app_info.db
update_DAC_for_db_file /opt/dbspace/.app_info.db-journal
-chsmack -a 'ail::db' /opt/dbspace/.app_info.db*
%postun
%{_libdir}/libail.so.0
%{_libdir}/libail.so.0.1.0
/usr/bin/ail_initdb
+/usr/bin/ail_fota
+/usr/bin/ail_desktop
+/usr/bin/ail_filter
+/usr/bin/ail_package
/usr/share/install-info/*
%files devel
{E_AIL_PROP_X_SLP_EXE_PATH, AIL_PROP_X_SLP_EXE_PATH},
{E_AIL_PROP_X_SLP_APPID_STR, AIL_PROP_X_SLP_APPID_STR},
{E_AIL_PROP_X_SLP_PKGID_STR, AIL_PROP_X_SLP_PKGID_STR},
- {E_AIL_PROP_X_SLP_DOMAIN_STR, AIL_PROP_X_SLP_DOMAIN_STR}
+ {E_AIL_PROP_X_SLP_DOMAIN_STR, AIL_PROP_X_SLP_DOMAIN_STR},
+ {E_AIL_PROP_X_SLP_SUBMODEMAINID_STR, AIL_PROP_X_SLP_SUBMODEMAINID_STR}
};
{E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
{E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
/* {E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL}, */
- {E_AIL_PROP_X_SLP_ENABLED_BOOL, AIL_PROP_X_SLP_ENABLED_BOOL}
+ {E_AIL_PROP_X_SLP_ENABLED_BOOL, AIL_PROP_X_SLP_ENABLED_BOOL},
+ {E_AIL_PROP_X_SLP_SUBMODE_BOOL, AIL_PROP_X_SLP_SUBMODE_BOOL}
};
if (expr) { \
_E("db_info.dbro: %s", sqlite3_errmsg(db_info.dbro)); \
_E("db_info.dbrw: %s", sqlite3_errmsg(db_info.dbrw)); \
+ _E("db_info.dbro errcode: %d", sqlite3_extended_errcode(db_info.dbro)); \
+ _E("db_info.dbrw errcode: %d", sqlite3_extended_errcode(db_info.dbrw)); \
return (val); \
} \
} while (0)
ret = sqlite3_prepare_v2(db_info.dbro, query, strlen(query), stmt, NULL);
if (ret != SQLITE_OK) {
_E("%s\n", sqlite3_errmsg(db_info.dbro));
+ _E("%d\n", sqlite3_extended_errcode(db_info.dbro));
return AIL_ERROR_DB_FAILED;
} else
return AIL_ERROR_OK;
char* x_slp_appid;
char* x_slp_pkgid;
char* x_slp_domain;
+ char* x_slp_submodemainid;
int x_slp_baselayoutwidth;
int x_slp_installedtime;
int nodisplay;
int x_slp_removable;
int x_slp_ishorizontalscale;
int x_slp_enabled;
+ int x_slp_submode;
char* desktop;
GSList* localname;
} desktop_info_s;
package = _get_package_from_icon(icon);
retv_if(!package, NULL);
+/* "db/setting/theme" is not exist */
+#if 0
theme = vconf_get_str("db/setting/theme");
if (!theme) {
theme = strdup("default");
return NULL;
}
}
+#else
+ theme = strdup("default");
+#endif
len = (0x01 << 7) + strlen(icon) + strlen(package) + strlen(theme);
icon_with_path = malloc(len);
return AIL_ERROR_OK;
}
+static ail_error_e _read_x_slp_submodemainid(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ SAFE_FREE_AND_STRDUP(value, info->x_slp_submodemainid);
+ retv_if(!info->x_slp_submodemainid, AIL_ERROR_OUT_OF_MEMORY);
+
+ return AIL_ERROR_OK;
+}
static ail_error_e _read_x_slp_uri(void *data, char *tag, char *value)
}
+static ail_error_e _read_x_slp_submode(void *data, char *tag, char *value)
+{
+ desktop_info_s *info = data;
+
+ retv_if(!data, AIL_ERROR_INVALID_PARAMETER);
+ retv_if(!value, AIL_ERROR_INVALID_PARAMETER);
+
+ info->x_slp_submode = !strcasecmp(value, "true");
+
+ return AIL_ERROR_OK;
+}
+
static ail_error_e _read_x_slp_appid(void *data, char *tag, char *value)
{
desktop_info_s *info = data;
.value_cb = _read_x_slp_packageid,
},
{
+ .field = "x-tizen-submodemainid",
+ .value_cb = _read_x_slp_submodemainid,
+ },
+ {
.field = "x-tizen-uri",
.value_cb = _read_x_slp_uri,
},
.value_cb = _read_x_slp_enabled,
},
{
+ .field = "x-tizen-submode",
+ .value_cb = _read_x_slp_submode,
+ },
+ {
.field = "x-tizen-multiple",
.value_cb = _read_x_slp_multiple,
},
if (info->x_slp_exe_path) len += strlen(info->x_slp_exe_path);
if (info->x_slp_appid) len += strlen(info->x_slp_appid);
if (info->desktop) len += strlen(info->desktop);
+ if (info->x_slp_submodemainid) len += strlen(info->x_slp_submodemainid);
return len;
}
info->x_slp_taskmanage = 1;
info->x_slp_removable = 1;
+ info->x_slp_submode = 0;
if(is_initdb)
info->x_slp_installedtime = 0;
SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_APPID_STR], info->x_slp_appid);
SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_PKGID_STR], info->x_slp_pkgid);
SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_DOMAIN_STR], info->x_slp_domain);
+ SAFE_FREE_AND_STRDUP(values[E_AIL_PROP_X_SLP_SUBMODEMAINID_STR], info->x_slp_submodemainid);
info->x_slp_installedtime = atoi(values[E_AIL_PROP_X_SLP_INSTALLEDTIME_INT]);
info->x_slp_removable = atoi(values[E_AIL_PROP_X_SLP_REMOVABLE_BOOL]);
info->x_slp_ishorizontalscale = atoi(values[E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL]);
info->x_slp_enabled = atoi(values[E_AIL_PROP_X_SLP_ENABLED_BOOL]);
+ info->x_slp_submode = atoi(values[E_AIL_PROP_X_SLP_SUBMODE_BOOL]);
err = AIL_ERROR_OK;
"x_slp_appid TEXT, "
"x_slp_pkgid TEXT, "
"x_slp_domain TEXT, "
+ "x_slp_submodemainid TEXT, "
"x_slp_baselayoutwidth INTEGER DEFAULT 0, "
"x_slp_installedtime INTEGER DEFAULT 0, "
"nodisplay INTEGER DEFAULT 0, "
"x_slp_removable INTEGER DEFAULT 1, "
"x_slp_ishorizontalscale INTEGER DEFAULT 0, "
"x_slp_enabled INTEGER DEFAULT 1, "
+ "x_slp_submode INTEGER DEFAULT 0, "
"desktop TEXT UNIQUE NOT NULL);",
"CREATE TABLE localname (package TEXT NOT NULL, "
"locale TEXT NOT NULL, "
struct name_item *item = (struct name_item *)data;
desktop_info_s *info = (desktop_info_s *)user_data;
- snprintf(query, sizeof(query), "insert into localname (package, locale, name, x_slp_pkgid) "
+ sqlite3_snprintf(sizeof(query), query, "insert into localname (package, locale, name, x_slp_pkgid) "
"values ('%s', '%s', '%s', '%s');",
info->package, item->locale, item->name, info->x_slp_pkgid);
if (db_exec(query) < 0)
"x_slp_appid, "
"x_slp_pkgid, "
"x_slp_domain, "
+ "x_slp_submodemainid, "
"x_slp_baselayoutwidth, "
"x_slp_installedtime, "
"nodisplay, "
"x_slp_removable, "
"x_slp_ishorizontalscale, "
"x_slp_enabled, "
+ "x_slp_submode, "
"desktop) "
"values "
"('%q', '%q', '%q', '%q', '%q', "
"'%q', '%q', '%q', '%q', '%q', "
"'%q', '%q', '%q', '%q', '%q', "
- "'%q', '%q', '%q', "
- "%d, %d, %d, %d, %d, %d, "
+ "'%q', '%q', '%q', '%q',"
+ "%d, %d, %d, %d, %d, %d, %d,"
"%d, %d, "
"'%q');",
info->package,
info->x_slp_appid,
info->x_slp_pkgid,
info->x_slp_domain,
+ info->x_slp_submodemainid,
info->x_slp_baselayoutwidth,
info->x_slp_installedtime,
info->nodisplay,
info->x_slp_removable,
info->x_slp_ishorizontalscale,
info->x_slp_enabled,
+ info->x_slp_submode,
info->desktop
);
if (info->localname)
g_slist_foreach(info->localname, _insert_localname, info);
- _D("Add (%s).", info->package);
+ _D("Add (%s).", query);
return AIL_ERROR_OK;
}
"x_slp_appid='%q', "
"x_slp_pkgid='%q', "
"x_slp_domain='%q', "
+ "x_slp_submodemainid='%q', "
"x_slp_baselayoutwidth=%d, "
"x_slp_installedtime=%d, "
"nodisplay=%d, "
"x_slp_removable=%d, "
"x_slp_ishorizontalscale=%d, "
"x_slp_enabled=%d, "
+ "x_slp_submode=%d, "
"desktop='%q'"
"where package='%q'",
info->exec,
info->x_slp_appid,
info->x_slp_pkgid,
info->x_slp_domain,
+ info->x_slp_submodemainid,
info->x_slp_baselayoutwidth,
info->x_slp_installedtime,
info->nodisplay,
info->x_slp_removable,
info->x_slp_ishorizontalscale,
info->x_slp_enabled,
+ info->x_slp_submode,
info->desktop,
info->package);
SAFE_FREE(info->x_slp_appid);
SAFE_FREE(info->x_slp_pkgid);
SAFE_FREE(info->x_slp_domain);
+ SAFE_FREE(info->x_slp_submodemainid);
SAFE_FREE(info->desktop);
if (info->localname) {
g_slist_free_full(info->localname, _name_item_free_func);
}
+EXPORT_API ail_error_e ail_desktop_fota(const char *appid)
+{
+ desktop_info_s info = {0,};
+ ail_error_e ret;
+ int count;
+
+ retv_if(!appid, AIL_ERROR_INVALID_PARAMETER);
+ if (!__is_authorized()) {
+ _E("You are not an authorized user on adding!\n");
+ return -1;
+ }
+
+ count = _count_all();
+ if (count <= 0) {
+ ret = _create_table();
+ if (ret != AIL_ERROR_OK) {
+ _D("Cannot create a table. Maybe there is already a table.");
+ }
+ }
+
+ ret = _init_desktop_info(&info, appid);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _read_desktop_info(&info);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ ret = _insert_desktop_info(&info);
+ retv_if(ret != AIL_ERROR_OK, AIL_ERROR_FAIL);
+
+ _fini_desktop_info(&info);
+
+ return AIL_ERROR_OK;
+}
+
EXPORT_API ail_error_e ail_desktop_appinfo_modify_bool(const char *appid,
const char *property,
bool value,
E_AIL_PROP_X_SLP_APPID_STR,
E_AIL_PROP_X_SLP_PKGID_STR,
E_AIL_PROP_X_SLP_DOMAIN_STR,
- E_AIL_PROP_STR_MAX = E_AIL_PROP_X_SLP_DOMAIN_STR,
+ E_AIL_PROP_X_SLP_SUBMODEMAINID_STR,
+ E_AIL_PROP_STR_MAX = E_AIL_PROP_X_SLP_SUBMODEMAINID_STR,
} ail_prop_str_e;
E_AIL_PROP_X_SLP_REMOVABLE_BOOL,
E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL,
E_AIL_PROP_X_SLP_ENABLED_BOOL,
- E_AIL_PROP_BOOL_MAX = E_AIL_PROP_X_SLP_ENABLED_BOOL,
+ E_AIL_PROP_X_SLP_SUBMODE_BOOL,
+ E_AIL_PROP_BOOL_MAX = E_AIL_PROP_X_SLP_SUBMODE_BOOL,
} ail_prop_bool_e;
#define NUM_OF_PROP E_AIL_PROP_BOOL_MAX + 1
"app_info.X_SLP_APPID='%s'",
"app_info.X_SLP_PKGID='%s'",
"app_info.X_SLP_DOMAIN='%s'",
+ "app_info.X_SLP_SUBMODEMAINID='%s'",
"app_info.X_SLP_BASELAYOUTWIDTH=%d",
"app_info.X_SLP_INSTALLEDTIME=%d",
"app_info.NODISPLAY=%d",
"app_info.X_SLP_REMOVABLE=%d",
"app_info.X_SLP_ISHORIZONTALSCALE=%d",
"app_info.X_SLP_ENABLED=%d",
+ "app_info.X_SLP_SUBMODE=%d",
NULL,
};
"app_info.X_SLP_APPID," \
"app_info.X_SLP_PKGID," \
"app_info.X_SLP_DOMAIN," \
+ "app_info.X_SLP_SUBMODEMAINID," \
"app_info.X_SLP_BASELAYOUTWIDTH," \
"app_info.X_SLP_INSTALLEDTIME," \
"app_info.NODISPLAY," \
"app_info.X_SLP_MULTIPLE," \
"app_info.X_SLP_REMOVABLE," \
"app_info.X_SLP_ISHORIZONTALSCALE," \
- "app_info.X_SLP_ENABLED" \
+ "app_info.X_SLP_ENABLED," \
+ "app_info.X_SLP_SUBMODE" \
#define SQL_FLD_APP_INFO_WITH_LOCALNAME SQL_FLD_APP_INFO",""localname.name"
--- /dev/null
+#AIL init DB build script
+
+SET(INITDB ail_initdb)
+SET(SRCS src/initdb.c)
+
+SET(FOTA ail_fota)
+SET(FOTASRCS src/ail_fota.c)
+
+SET(DESKTOP ail_desktop)
+SET(DESKSRCS src/ail_desktop.c)
+
+SET(FILTER ail_filter)
+SET(FILTERSRCS src/ail_filter.c)
+
+SET(PKG ail_package)
+SET(PKGSRCS src/ail_package.c)
+
+pkg_check_modules(INITDB_PKGS REQUIRED vconf dlog db-util sqlite3)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${INITDB_PKGS_CFLAGS}")
+
+ADD_EXECUTABLE(${INITDB} ${SRCS})
+TARGET_LINK_LIBRARIES(${INITDB} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${INITDB} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${INITDB} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${INITDB} DESTINATION ${BINDIR})
+
+ADD_EXECUTABLE(${FOTA} ${FOTASRCS})
+TARGET_LINK_LIBRARIES(${FOTA} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${FOTA} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${FOTA} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${FOTA} DESTINATION ${BINDIR})
+
+ADD_EXECUTABLE(${DESKTOP} ${DESKSRCS})
+TARGET_LINK_LIBRARIES(${DESKTOP} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${DESKTOP} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${DESKTOP} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${DESKTOP} DESTINATION ${BINDIR})
+
+ADD_EXECUTABLE(${FILTER} ${FILTERSRCS})
+TARGET_LINK_LIBRARIES(${FILTER} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${FILTER} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${FILTER} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${FILTER} DESTINATION ${BINDIR})
+
+ADD_EXECUTABLE(${PKG} ${PKGSRCS})
+TARGET_LINK_LIBRARIES(${PKG} ${LIBNAME} ${INITDB_PKGS_LIBRARIES})
+SET_TARGET_PROPERTIES(${PKG} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+SET_TARGET_PROPERTIES(${PKG} PROPERTIES SKIP_BUILD_RPATH true)
+
+INSTALL(TARGETS ${PKG} DESTINATION ${BINDIR})
\ No newline at end of file
--- /dev/null
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that
+this software is owned by Samsung and you
+shall not disclose such Confidential Information and shall
+use it only in accordance with the terms of the license agreement
+you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no
+representations or warranties about the suitability
+of the software, either express or implied, including but not
+limited to the implied warranties of merchantability, fitness for
+a particular purpose, or non-infringement.
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or
+related to this software.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include <ail.h>
+
+
+static void _print_help(const char *cmd)
+{
+ fprintf(stderr, "Usage:\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "[Add a desktop]\n");
+ fprintf(stderr, " %s add <PACKAGE NAME>\n", cmd);
+ fprintf(stderr, "\n");
+ fprintf(stderr, " Ex) %s add com.samsung.menu-screen\n", cmd);
+ fprintf(stderr, "\n");
+ fprintf(stderr, "[Update a desktop]\n");
+ fprintf(stderr, " %s update <PACKAGE NAME>\n", cmd);
+ fprintf(stderr, "\n");
+ fprintf(stderr, " Ex) %s update com.samsung.menu-screen\n", cmd);
+ fprintf(stderr, "\n");
+ fprintf(stderr, "[Remove a desktop]\n");
+ fprintf(stderr, " %s remove <PACKAGE NAME>\n", cmd);
+ fprintf(stderr, "\n");
+ fprintf(stderr, " Ex) %s remove com.samsung.menu-screen\n", cmd);
+ fprintf(stderr, "\n");
+}
+
+
+
+static ail_error_e _add_desktop(const char *package)
+{
+ ail_error_e ret;
+
+ if (!package) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_add(package);
+ 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) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_update(package);
+ 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) {
+ return AIL_ERROR_FAIL;
+ }
+
+ ret = ail_desktop_remove(package);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+
+
+int main(int argc, char** argv)
+{
+ ail_error_e ret = AIL_ERROR_OK;
+
+ if (3 == argc) {
+ if (!strncmp(argv[1], "add", 3)) {
+ ret = _add_desktop(argv[2]);
+ } else if (!strncmp(argv[1], "update", 6)) {
+ ret = _update_desktop(argv[2]);
+ } else if (!strncmp(argv[1], "remove", 6)) {
+ ret = _remove_desktop(argv[2]);
+ } else {
+ fprintf(stderr, "%s is a invalid command\n", argv[1]);
+ }
+ }
+ else {
+ _print_help(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if (ret != AIL_ERROR_OK) {
+ fprintf(stderr, "There are some problems\n");
+ }
+
+ return EXIT_SUCCESS;
+}
+
--- /dev/null
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that
+this software is owned by Samsung and you
+shall not disclose such Confidential Information and shall
+use it only in accordance with the terms of the license agreement
+you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no
+representations or warranties about the suitability
+of the software, either express or implied, including but not
+limited to the implied warranties of merchantability, fitness for
+a particular purpose, or non-infringement.
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or
+related to this software.
+*/
+
+
+#include <stdio.h>
+#include <getopt.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include "ail.h"
+#include "ail_private.h"
+
+enum {
+ _CMD_UNKNOWN,
+ _CMD_COUNT,
+ _CMD_FILTER,
+};
+
+static void usage(const char *name)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, " Usage: %s -c command [options]\n", name);
+ fprintf(stderr, " command:\n");
+ fprintf(stderr, " c : count appinfos by option\n");
+ fprintf(stderr, " f : filter appinfos by option\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, " option:\n");
+ fprintf(stderr, " --package=<pacakge name>\n");
+ fprintf(stderr, " --exec=<exec file>\n");
+ fprintf(stderr, " --name=<title name>\n");
+ fprintf(stderr, " --type=<type>\n");
+ fprintf(stderr, " --icon=<icon file>\n");
+ fprintf(stderr, " --category=<category>\n");
+ fprintf(stderr, " --version=<version>\n");
+ fprintf(stderr, " --mimetype=<mimetype>\n");
+ fprintf(stderr, " --nodisplay=<{0|1}>\n");
+ fprintf(stderr, " --service=<service>\n");
+ fprintf(stderr, " --packagetype=<package type>\n");
+ fprintf(stderr, " --packagecategories=<package category>\n");
+ fprintf(stderr, " --packageid=<package id>\n");
+ fprintf(stderr, " --svc=<action:scheme:mime>\n");
+ fprintf(stderr, " --taskmanage=<{true|false}>\n");
+ fprintf(stderr, " --multiple=<{true|false}>\n");
+ fprintf(stderr, " --removable=<{true|false}>\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, " Example:\n");
+ fprintf(stderr, " %s -n menu-screen -r 1\n", name);
+ fprintf(stderr, "\n");
+}
+
+struct _ail_map_t {
+ int prop;
+ const char *property;
+};
+
+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_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_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},
+ {E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
+ {E_AIL_PROP_X_SLP_APPID_STR, AIL_PROP_X_SLP_APPID_STR},
+ {E_AIL_PROP_X_SLP_PKGID_STR, AIL_PROP_X_SLP_PKGID_STR},
+ {E_AIL_PROP_X_SLP_DOMAIN_STR, AIL_PROP_X_SLP_DOMAIN_STR},
+ {E_AIL_PROP_X_SLP_SUBMODEMAINID_STR, AIL_PROP_X_SLP_SUBMODEMAINID_STR},
+ {E_AIL_PROP_X_SLP_TEMP_INT, AIL_PROP_X_SLP_TEMP_INT},
+ {E_AIL_PROP_X_SLP_INSTALLEDTIME_INT, AIL_PROP_X_SLP_INSTALLEDTIME_INT},
+ {E_AIL_PROP_NODISPLAY_BOOL, AIL_PROP_NODISPLAY_BOOL},
+ {E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_X_SLP_TASKMANAGE_BOOL},
+ {E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
+ {E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
+ {E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL},
+ {E_AIL_PROP_X_SLP_ENABLED_BOOL, AIL_PROP_X_SLP_ENABLED_BOOL},
+ {E_AIL_PROP_X_SLP_SUBMODE_BOOL, AIL_PROP_X_SLP_SUBMODE_BOOL}
+};
+
+static const char *_ail_convert_to_property(int prop)
+{
+ int i = 0;
+
+ 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) {
+ return prop_map[i].property;
+ }
+ }
+
+ return NULL;
+}
+
+
+
+static int _get_cmd(const char *arg)
+{
+ int r;
+ int a;
+
+ if(!arg)
+ a = 0;
+ else
+ a = (int)*arg;
+
+ switch (a) {
+ case 'c':
+ case 'C':
+ r = _CMD_COUNT;
+ break;
+ case 'f':
+ case 'F':
+ r = _CMD_FILTER;
+ break;
+ default:
+ r = _CMD_UNKNOWN;
+ break;
+ }
+
+ return r;
+}
+
+ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data)
+{
+ char *rs = NULL;
+ int t=-1;
+ bool b = 0;
+ int n = 0;
+ struct element e;
+ int i=0;
+ struct element *p;
+ 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 ++) {
+ 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;
+ }
+ }
+ printf("\n");
+ return ret;
+}
+
+
+
+int main(int argc, char *argv[])
+{
+ int o;
+ bool err;
+ ail_filter_h f;
+ int oi;
+ int c;
+ static struct element e;
+ int t;
+
+ f = NULL;
+ oi = -1;
+ c = _CMD_UNKNOWN;
+
+ static const struct option longopts[] = {
+ { "help", 0, NULL, 'h' },
+ { "command", 1, NULL, 'c' },
+ { "package", 1, &(e.prop), E_AIL_PROP_PACKAGE_STR},
+ { "name", 1, &(e.prop), E_AIL_PROP_NAME_STR },
+ { "mimetype", 1, &(e.prop), E_AIL_PROP_MIMETYPE_STR},
+ { "removable", 1, &(e.prop), E_AIL_PROP_X_SLP_REMOVABLE_BOOL },
+ { "exec", 1, &(e.prop), E_AIL_PROP_EXEC_STR},
+ { "type", 1, &(e.prop), E_AIL_PROP_TYPE_STR},
+ { "icon", 1, &(e.prop), E_AIL_PROP_ICON_STR},
+ { "categories", 1, &(e.prop), E_AIL_PROP_CATEGORIES_STR},
+ { "version", 1, &(e.prop), E_AIL_PROP_VERSION_STR},
+ { "mimetype", 1, &(e.prop), E_AIL_PROP_MIMETYPE_STR},
+ { "nodisplay", 1, &(e.prop), E_AIL_PROP_NODISPLAY_BOOL},
+ { "service", 1, &(e.prop), E_AIL_PROP_X_SLP_SERVICE_STR},
+ { "packagetype", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGETYPE_STR},
+ { "packagecategories", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR},
+ { "packageid", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGEID_STR},
+ { "svc", 1, &(e.prop), E_AIL_PROP_X_SLP_SVC_STR},
+ { "taskmanage", 1, &(e.prop), E_AIL_PROP_X_SLP_TASKMANAGE_BOOL},
+ { "multiple", 1, &(e.prop), E_AIL_PROP_X_SLP_MULTIPLE_BOOL},
+ { "removable", 1, &(e.prop), E_AIL_PROP_X_SLP_REMOVABLE_BOOL},
+ { "appid", 1, &(e.prop), AIL_PROP_X_SLP_APPID_STR},
+ { "pkgid", 1, &(e.prop), AIL_PROP_X_SLP_PKGID_STR},
+ { "submode", 1, &(e.prop), E_AIL_PROP_X_SLP_SUBMODE_BOOL},
+ { "submodemainid", 1, &(e.prop), AIL_PROP_X_SLP_SUBMODEMAINID_STR},
+ { "domain", 1, &(e.prop), AIL_PROP_X_SLP_DOMAIN_STR},
+ { 0, 0, 0, 0 },
+ };
+
+ if (ail_filter_new(&f) != AIL_ERROR_OK)
+ return -1;
+
+ err = false;
+
+ while (!err && (o = getopt_long(argc, argv, "c:", longopts, &oi)) >= 0) {
+ bool b;
+ struct element *p = &e;
+
+ 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;
+ }
+ break;
+ default:
+ err = true;
+ break;
+ }
+ }
+
+ 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;
+ }
+ }
+
+ if (f)
+ ail_filter_destroy(f);
+
+ return 0;
+}
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "ail.h"
+#include "ail_private.h"
+
+#define OWNER_ROOT 0
+#define GROUP_MENU 6010
+#define BUFSZE 1024
+#define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
+#define USR_DESKTOP_DIRECTORY "/usr/share/applications"
+#define APP_INFO_DB_FILE "/opt/dbspace/.app_info.db"
+#define APP_INFO_DB_FILE_JOURNAL "/opt/dbspace/.app_info.db-journal"
+#define APP_INFO_DB_LABEL "ail::db"
+
+#ifdef _E
+#undef _E
+#endif
+#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);
+
+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)
+{
+ char *package, *tmp;
+
+ retv_if(!desktop, NULL);
+
+ package = strdup(desktop);
+ retv_if(!package, NULL);
+
+ tmp = strrchr(package, '.');
+ if(tmp == NULL) {
+ _E("[%s] is not a desktop file", package);
+ free(package);
+ return NULL;
+ }
+
+ if (strcmp(tmp, ".desktop")) {
+ _E("%s is not a desktop file", desktop);
+ free(package);
+ return NULL;
+ }
+
+ *tmp = '\0';
+
+ return package;
+}
+
+
+
+int initdb_load_directory(const char *directory)
+{
+ DIR *dir;
+ struct dirent entry, *result;
+ int len, ret;
+ char buf[BUFSZE];
+ int total_cnt = 0;
+ int ok_cnt = 0;
+
+ // desktop file
+ dir = opendir(directory);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _E("Failed to access the [%s] because %s\n", directory, buf);
+ return AIL_ERROR_FAIL;
+ }
+
+ len = strlen(directory) + 1;
+ _D("Loading desktop files from %s", directory);
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+ char *package;
+
+ if (entry.d_name[0] == '.') continue;
+ total_cnt++;
+ package = _desktop_to_package(entry.d_name);
+ if (!package) {
+ _E("Failed to convert file to package[%s]", entry.d_name);
+ continue;
+ }
+
+ if (ail_desktop_fota(package) != AIL_ERROR_OK) {
+ _E("Failed to add a package[%s]", package);
+ } else {
+ ok_cnt++;
+ }
+ free(package);
+ }
+
+ _D("Application-Desktop process : Success [%d], fail[%d], total[%d] \n", ok_cnt, total_cnt-ok_cnt, total_cnt);
+ closedir(dir);
+
+ 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;
+
+ 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], OWNER_ROOT, 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()
+{
+ /* ail_init db should be called by as root privilege. */
+
+ uid_t uid = getuid();
+ if ((uid_t) 0 == uid)
+ return 1;
+ else
+ return 0;
+}
+
+int xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ if (!__is_authorized()) {
+ fprintf(stderr, "You are not an authorized user!\n");
+ _D("You are not an authorized user!\n");
+ return AIL_ERROR_FAIL;
+ }
+
+ const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL };
+ xsystem(argv_rm);
+ const char *argv_rmjn[] = { "/bin/rm", APP_INFO_DB_FILE_JOURNAL, NULL };
+ xsystem(argv_rmjn);
+
+ ret = setenv("AIL_INITDB", "1", 1);
+ _D("AIL_INITDB : %d", ret);
+
+ ret = initdb_count_app();
+ if (ret > 0) {
+ _D("Some Apps in the App Info DB.");
+ }
+
+ ret = initdb_load_directory(OPT_DESKTOP_DIRECTORY);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot load opt desktop directory.");
+ }
+
+ ret = initdb_load_directory(USR_DESKTOP_DIRECTORY);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot load usr desktop directory.");
+ }
+
+ ret = initdb_change_perm(APP_INFO_DB_FILE);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot chown.");
+ }
+
+ const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
+ xsystem(argv_smack);
+ const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
+ xsystem(argv_smackjn);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+// END
--- /dev/null
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that
+this software is owned by Samsung and you
+shall not disclose such Confidential Information and shall
+use it only in accordance with the terms of the license agreement
+you entered into with SAMSUNG ELECTRONICS. SAMSUNG make no
+representations or warranties about the suitability
+of the software, either express or implied, including but not
+limited to the implied warranties of merchantability, fitness for
+a particular purpose, or non-infringement.
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or
+related to this software.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include <ail.h>
+#include "ail_private.h"
+
+char *prop_tbl[] = {
+ AIL_PROP_PACKAGE_STR,
+ AIL_PROP_EXEC_STR,
+ AIL_PROP_NAME_STR,
+ AIL_PROP_TYPE_STR,
+ AIL_PROP_ICON_STR,
+ AIL_PROP_CATEGORIES_STR,
+ AIL_PROP_VERSION_STR,
+ AIL_PROP_MIMETYPE_STR,
+ AIL_PROP_X_SLP_SERVICE_STR,
+ AIL_PROP_X_SLP_PACKAGETYPE_STR,
+ AIL_PROP_X_SLP_PACKAGECATEGORIES_STR,
+ AIL_PROP_X_SLP_PACKAGEID_STR,
+ AIL_PROP_X_SLP_SVC_STR,
+ AIL_PROP_X_SLP_EXE_PATH,
+ AIL_PROP_X_SLP_APPID_STR,
+ AIL_PROP_X_SLP_PKGID_STR,
+ AIL_PROP_X_SLP_DOMAIN_STR,
+ AIL_PROP_X_SLP_SUBMODEMAINID_STR,
+ AIL_PROP_NODISPLAY_BOOL,
+ AIL_PROP_X_SLP_TASKMANAGE_BOOL,
+ AIL_PROP_X_SLP_MULTIPLE_BOOL,
+ AIL_PROP_X_SLP_REMOVABLE_BOOL,
+ AIL_PROP_X_SLP_SUBMODE_BOOL,
+ NULL
+};
+
+
+static void _print_help(const char *cmd)
+{
+ int i;
+
+ fprintf(stderr, "Usage:\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "[Get appinfo value]\n");
+ fprintf(stderr, " %s get <PACKAGE NAME> <COLUMN NAME>\n", cmd);
+ fprintf(stderr, "\n");
+ fprintf(stderr, " <COLUMN NAME>\n");
+
+ 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) {
+ return 0;
+ }
+
+ for (i = 0; prop_tbl[i]; i++) {
+ if (!strcasecmp(prop_tbl[i], property)) {
+ return i;
+ }
+ }
+
+ fprintf(stderr, "%s is not found\n", property);
+
+ return -1;
+}
+
+
+
+static ail_error_e _get_appinfo(const char *package, const char *property)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ int prop, ival;
+ bool bval;
+ char *str;
+ struct element e;
+ struct element *p;
+ int t;
+
+ ret = ail_package_get_appinfo(package, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ prop = _get_property(property);
+ if (prop < 0) {
+ goto END;
+ }
+
+ e.prop = prop;
+ p = &e;
+ ELEMENT_TYPE(p,t);
+
+ if (t == VAL_TYPE_STR) {
+ ret = ail_appinfo_get_str(handle, property, &str);
+ if (ret != AIL_ERROR_OK) {
+ goto END;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
+ } else if (t == VAL_TYPE_INT) {
+ ret = ail_appinfo_get_int(handle, property, &ival);
+ if (ret != AIL_ERROR_OK) {
+ goto END;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, ival);
+ } else if (t == VAL_TYPE_BOOL) {
+ ret = ail_appinfo_get_bool(handle, property, &bval);
+ if (ret != AIL_ERROR_OK) {
+ goto END;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, bval);
+ }
+
+END:
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+int main(int argc, char** argv)
+{
+ ail_error_e ret = AIL_ERROR_OK;
+
+
+ if (4 == argc) {
+ if (!strncmp(argv[1], "get", 3)) {
+ ret = _get_appinfo(argv[2], argv[3]);
+ }
+ }
+ else {
+ _print_help(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if (ret != AIL_ERROR_OK) {
+ fprintf(stderr, "There are some problems\n");
+ }
+
+ return EXIT_SUCCESS;
+}
+
+
--- /dev/null
+/*
+ * ail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <dirent.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+#include "ail.h"
+#include "ail_private.h"
+
+#define OWNER_ROOT 0
+#define GROUP_MENU 6010
+#define BUFSZE 1024
+#define OPT_DESKTOP_DIRECTORY "/opt/share/applications"
+#define USR_DESKTOP_DIRECTORY "/usr/share/applications"
+#define APP_INFO_DB_FILE "/opt/dbspace/.app_info.db"
+#define APP_INFO_DB_FILE_JOURNAL "/opt/dbspace/.app_info.db-journal"
+#define APP_INFO_DB_LABEL "ail::db"
+
+#ifdef _E
+#undef _E
+#endif
+#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);
+
+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)
+{
+ char *package, *tmp;
+
+ retv_if(!desktop, NULL);
+
+ package = strdup(desktop);
+ retv_if(!package, NULL);
+
+ tmp = strrchr(package, '.');
+ if(tmp == NULL) {
+ _E("[%s] is not a desktop file", package);
+ free(package);
+ return NULL;
+ }
+
+ if (strcmp(tmp, ".desktop")) {
+ _E("%s is not a desktop file", desktop);
+ free(package);
+ return NULL;
+ }
+
+ *tmp = '\0';
+
+ return package;
+}
+
+
+
+int initdb_load_directory(const char *directory)
+{
+ DIR *dir;
+ struct dirent entry, *result;
+ int len, ret;
+ char buf[BUFSZE];
+ int total_cnt = 0;
+ int ok_cnt = 0;
+
+ // desktop file
+ dir = opendir(directory);
+ if (!dir) {
+ if (strerror_r(errno, buf, sizeof(buf)) == 0)
+ _E("Failed to access the [%s] because %s\n", directory, buf);
+ return AIL_ERROR_FAIL;
+ }
+
+ len = strlen(directory) + 1;
+ _D("Loading desktop files from %s", directory);
+
+ for (ret = readdir_r(dir, &entry, &result);
+ ret == 0 && result != NULL;
+ ret = readdir_r(dir, &entry, &result)) {
+ char *package;
+
+ if (entry.d_name[0] == '.') continue;
+ total_cnt++;
+ package = _desktop_to_package(entry.d_name);
+ if (!package) {
+ _E("Failed to convert file to package[%s]", entry.d_name);
+ continue;
+ }
+
+ if (ail_desktop_add(package) != AIL_ERROR_OK) {
+ _E("Failed to add a package[%s]", package);
+ } else {
+ ok_cnt++;
+ }
+ free(package);
+ }
+
+ _D("Application-Desktop process : Success [%d], fail[%d], total[%d] \n", ok_cnt, total_cnt-ok_cnt, total_cnt);
+ closedir(dir);
+
+ 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;
+
+ 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], OWNER_ROOT, 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()
+{
+ /* ail_init db should be called by as root privilege. */
+
+ uid_t uid = getuid();
+ if ((uid_t) 0 == uid)
+ return 1;
+ else
+ return 0;
+}
+
+int xsystem(const char *argv[])
+{
+ int status = 0;
+ pid_t pid;
+ pid = fork();
+ switch (pid) {
+ case -1:
+ perror("fork failed");
+ return -1;
+ case 0:
+ /* child */
+ execvp(argv[0], (char *const *)argv);
+ _exit(-1);
+ default:
+ /* parent */
+ break;
+ }
+ if (waitpid(pid, &status, 0) == -1) {
+ perror("waitpid failed");
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ perror("signal");
+ return -1;
+ }
+ if (!WIFEXITED(status)) {
+ /* shouldn't happen */
+ perror("should not happen");
+ return -1;
+ }
+ return WEXITSTATUS(status);
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ if (!__is_authorized()) {
+ fprintf(stderr, "You are not an authorized user!\n");
+ _D("You are not an authorized user!\n");
+ return AIL_ERROR_FAIL;
+ }
+
+ const char *argv_rm[] = { "/bin/rm", APP_INFO_DB_FILE, NULL };
+ xsystem(argv_rm);
+ const char *argv_rmjn[] = { "/bin/rm", APP_INFO_DB_FILE_JOURNAL, NULL };
+ xsystem(argv_rmjn);
+
+ ret = setenv("AIL_INITDB", "1", 1);
+ _D("AIL_INITDB : %d", ret);
+
+ ret = initdb_count_app();
+ if (ret > 0) {
+ _D("Some Apps in the App Info DB.");
+ }
+
+ ret = initdb_load_directory(OPT_DESKTOP_DIRECTORY);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot load opt desktop directory.");
+ }
+
+ ret = initdb_load_directory(USR_DESKTOP_DIRECTORY);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot load usr desktop directory.");
+ }
+
+ ret = initdb_change_perm(APP_INFO_DB_FILE);
+ if (ret == AIL_ERROR_FAIL) {
+ _E("cannot chown.");
+ }
+
+ const char *argv_smack[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE, NULL };
+ xsystem(argv_smack);
+ const char *argv_smackjn[] = { "/usr/bin/chsmack", "-a", APP_INFO_DB_LABEL, APP_INFO_DB_FILE_JOURNAL, NULL };
+ xsystem(argv_smackjn);
+
+ return AIL_ERROR_OK;
+}
+
+
+
+// END
--- /dev/null
+/*
+ * Copyright (c) 2011 Samsung Electronics, Inc.
+ * All rights reserved.
+ *
+ * This software is a confidential and proprietary information
+ * of Samsung Electronics, Inc. ("Confidential Information"). You
+ * shall not disclose such Confidential Information and shall use
+ * it only in accordance with the terms of the license agreement
+ * you entered into with Samsung Electronics.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include <ail.h>
+#include "ail_private.h"
+
--- /dev/null
+
+
+static void _print_help(const char *cmd)
+{
+ int i;
+
+ fprintf(stderr, "Usage:\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "[Get appinfo value]\n");
+ fprintf(stderr, " %s get <PACKAGE NAME> <COLUMN NAME>\n", cmd);
+ fprintf(stderr, "\n");
+ fprintf(stderr, " <COLUMN NAME>\n");
+
+ 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) {
+ return 0;
+ }
+
+ for (i = 0; prop_tbl[i]; i++) {
+ if (!strcasecmp(prop_tbl[i], property)) {
+ return i;
+ }
+ }
+
+ fprintf(stderr, "%s is not found\n", property);
+
+ return -1;
+}
+
+
+
+static ail_error_e _get_appinfo(const char *package, const char *property)
+{
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ int prop, ival;
+ bool bval;
+ char *str;
+ struct element e;
+ struct element *p;
+ int t;
+
+ ret = ail_package_get_appinfo(package, &handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ prop = _get_property(property);
+ if (prop < 0) {
+ return AIL_ERROR_FAIL;
+ }
+
+ e.prop = prop;
+ p = &e;
+ ELEMENT_TYPE(p,t);
+
+ if (t == VAL_TYPE_STR) {
+ ret = ail_appinfo_get_str(handle, prop, &str);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %s\n", package, property, str);
+ } else if (t == VAL_TYPE_INT) {
+ ret = ail_appinfo_get_int(handle, prop, &ival);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, ival);
+ } else if (t == VAL_TYPE_BOOL) {
+ ret = ail_appinfo_get_bool(handle, prop, &bval);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+ fprintf(stderr, "Package[%s], Property[%s] : %d\n", package, property, bval);
+ }
+
+ ret = ail_package_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ return AIL_ERROR_FAIL;
+ }
+
+ return AIL_ERROR_OK;
+}
+
+int main(int argc, char** argv)
+{
+ ail_error_e ret = AIL_ERROR_OK;
+
+
+ if (4 == argc) {
+ if (!strncmp(argv[1], "get", 3)) {
+ ret = _get_appinfo(argv[2], argv[3]);
+ }
+ }
+ else {
+ _print_help(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if (ret != AIL_ERROR_OK) {
+ fprintf(stderr, "There are some problems\n");
+ }
+
+ return EXIT_SUCCESS;
+}
+
+