--- /dev/null
+Jayoun Lee <airjany@samsung.com>
+Sewook Park <sewook7.park@samsung.com>
+Jaeho Lee <jaeho81.lee@samsung.com>
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+PROJECT(aul C)
+SET(VERSION_MAJOR 0)
+SET(VERSION "${VERSION_MAJOR}.1.0")
+
+### Global setting ###
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(EXEC_PREFIX "\${prefix}")
+SET(LIBDIR "\${prefix}/lib")
+SET(INCLUDEDIR "\${prefix}/include/aul")
+
+# Build type : Release
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Release")
+ENDIF()
+MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
+
+
+# Set required packages
+INCLUDE(FindPkgConfig)
+
+pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control app-checker rua glib-2.0 ecore-x ecore-input evas vconf pkgmgr-info app2sd)
+pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime app-checker libsmack)
+PKG_CHECK_MODULES(PKGS REQUIRED glib-2.0 gio-2.0 dlog bundle)
+
+FIND_LIBRARY(LIB_DL dl)
+
+FOREACH(flag ${libpkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(TEST_CFLAGS "${TEST_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+# Compiler flags
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/legacy)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/feature)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs" )
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fpic")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_C_FLAGS_RELEASE "-O2")
+
+SET(CMAKE_SKIP_BUILD_RPATH true)
+
+# Get uname value to set 'TARGET' definition
+# TODO: Is this needed?
+FIND_PROGRAM(UNAME NAMES uname)
+EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH")
+IF("${ARCH}" STREQUAL "arm")
+ ADD_DEFINITIONS("-DTARGET")
+ MESSAGE("add -DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DSHARE_PREFIX=\"/usr/share/aul\"")
+
+# Linker flags
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+
+### Build ###
+
+# aul_mods : modules (static library)
+add_library(aul_mods STATIC
+ src/app_sock.c
+ src/simple_util.c
+ )
+
+# aul
+add_library(aul SHARED
+ src/pkginfo.c
+ src/launch.c
+ src/launch_glib.c
+ src/launch_with_result.c
+ src/service.c
+ src/mime.c
+ src/mida.c
+ src/miregex.c
+ src/app_signal.c
+ src/key.c
+ src/status.c
+ )
+target_link_libraries(aul aul_mods ${libpkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(aul PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(aul PROPERTIES VERSION ${VERSION})
+
+# launchpad(old avatar) daemon
+SET(AVATAR_NAME "launchpad_preloading_preinitializing_daemon")
+add_executable(${AVATAR_NAME}
+ launchpad_src/launchpad.c
+ launchpad_src/util_x.c
+ )
+
+MESSAGE(" "${pkgs_LDFLAGS})
+target_link_libraries(${AVATAR_NAME} aul_mods aul ${pkgs_LDFLAGS} ${LIB_DL})
+set_target_properties(${AVATAR_NAME}
+ PROPERTIES SKIP_BUILD_RPATH true
+ ) # remove rpath option that is automatically generated by cmake.
+
+add_executable(amd
+ am_daemon/amd_main.c
+ am_daemon/amd_key.c
+ am_daemon/amd_request.c
+ am_daemon/amd_appinfo.c
+ am_daemon/amd_cgutil.c
+ am_daemon/amd_launch.c
+ am_daemon/amd_status.c
+ )
+target_link_libraries(amd aul_mods app-checker-server rua glib-2.0 bundle ail aul utilX ${pkgs_LDFLAGS})
+
+SET(REL_AGENT daemon-manager-release-agent)
+ADD_EXECUTABLE(${REL_AGENT} agent/${REL_AGENT}.c)
+TARGET_LINK_LIBRARIES(${REL_AGENT} ${PKGS_LDFLAGS} aul aul_mods)
+SET_TARGET_PROPERTIES(${REL_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+INSTALL(TARGETS ${REL_AGENT} DESTINATION bin)
+
+SET(LAUNCH_AGENT daemon-manager-launch-agent)
+ADD_EXECUTABLE(${LAUNCH_AGENT} agent/${LAUNCH_AGENT}.c)
+TARGET_LINK_LIBRARIES(${LAUNCH_AGENT} ${PKGS_LDFLAGS})
+SET_TARGET_PROPERTIES(${LAUNCH_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+INSTALL(TARGETS ${LAUNCH_AGENT} DESTINATION bin)
+
+
+
+# pkgconfig file
+CONFIGURE_FILE(aul.pc.in aul.pc @ONLY)
+
+
+### Install ###
+INSTALL(TARGETS aul DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(TARGETS ${AVATAR_NAME} DESTINATION bin)
+INSTALL(TARGETS amd DESTINATION bin)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul.h DESTINATION include/aul)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_service.h DESTINATION include/aul)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/SLP_AUL_PG.h DESTINATION include/aul)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_service.sh DESTINATION bin)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_service_test.sh DESTINATION bin)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/aul_mime.sh DESTINATION bin)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/aul.pc DESTINATION lib/pkgconfig)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/legacy/preload_list.txt DESTINATION /usr/share/aul )
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/feature/preexec_list.txt DESTINATION /usr/share/aul )
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/mida_db.sql DESTINATION /usr/share/aul )
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION /usr/share/aul )
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/service DESTINATION /usr/share/aul )
+
+# test
+add_subdirectory(test)
+
--- /dev/null
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+ Apache License\r
+ Version 2.0, January 2004\r
+ http://www.apache.org/licenses/\r
+\r
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+ 1. Definitions.\r
+\r
+ "License" shall mean the terms and conditions for use, reproduction,\r
+ and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+ "Licensor" shall mean the copyright owner or entity authorized by\r
+ the copyright owner that is granting the License.\r
+\r
+ "Legal Entity" shall mean the union of the acting entity and all\r
+ other entities that control, are controlled by, or are under common\r
+ control with that entity. For the purposes of this definition,\r
+ "control" means (i) the power, direct or indirect, to cause the\r
+ direction or management of such entity, whether by contract or\r
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+ outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+ "You" (or "Your") shall mean an individual or Legal Entity\r
+ exercising permissions granted by this License.\r
+\r
+ "Source" form shall mean the preferred form for making modifications,\r
+ including but not limited to software source code, documentation\r
+ source, and configuration files.\r
+\r
+ "Object" form shall mean any form resulting from mechanical\r
+ transformation or translation of a Source form, including but\r
+ not limited to compiled object code, generated documentation,\r
+ and conversions to other media types.\r
+\r
+ "Work" shall mean the work of authorship, whether in Source or\r
+ Object form, made available under the License, as indicated by a\r
+ copyright notice that is included in or attached to the work\r
+ (an example is provided in the Appendix below).\r
+\r
+ "Derivative Works" shall mean any work, whether in Source or Object\r
+ form, that is based on (or derived from) the Work and for which the\r
+ editorial revisions, annotations, elaborations, or other modifications\r
+ represent, as a whole, an original work of authorship. For the purposes\r
+ of this License, Derivative Works shall not include works that remain\r
+ separable from, or merely link (or bind by name) to the interfaces of,\r
+ the Work and Derivative Works thereof.\r
+\r
+ "Contribution" shall mean any work of authorship, including\r
+ the original version of the Work and any modifications or additions\r
+ to that Work or Derivative Works thereof, that is intentionally\r
+ submitted to Licensor for inclusion in the Work by the copyright owner\r
+ or by an individual or Legal Entity authorized to submit on behalf of\r
+ the copyright owner. For the purposes of this definition, "submitted"\r
+ means any form of electronic, verbal, or written communication sent\r
+ to the Licensor or its representatives, including but not limited to\r
+ communication on electronic mailing lists, source code control systems,\r
+ and issue tracking systems that are managed by, or on behalf of, the\r
+ Licensor for the purpose of discussing and improving the Work, but\r
+ excluding communication that is conspicuously marked or otherwise\r
+ designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+ "Contributor" shall mean Licensor and any individual or Legal Entity\r
+ on behalf of whom a Contribution has been received by Licensor and\r
+ subsequently incorporated within the Work.\r
+\r
+ 2. Grant of Copyright License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ copyright license to reproduce, prepare Derivative Works of,\r
+ publicly display, publicly perform, sublicense, and distribute the\r
+ Work and such Derivative Works in Source or Object form.\r
+\r
+ 3. Grant of Patent License. Subject to the terms and conditions of\r
+ this License, each Contributor hereby grants to You a perpetual,\r
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+ (except as stated in this section) patent license to make, have made,\r
+ use, offer to sell, sell, import, and otherwise transfer the Work,\r
+ where such license applies only to those patent claims licensable\r
+ by such Contributor that are necessarily infringed by their\r
+ Contribution(s) alone or by combination of their Contribution(s)\r
+ with the Work to which such Contribution(s) was submitted. If You\r
+ institute patent litigation against any entity (including a\r
+ cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+ or a Contribution incorporated within the Work constitutes direct\r
+ or contributory patent infringement, then any patent licenses\r
+ granted to You under this License for that Work shall terminate\r
+ as of the date such litigation is filed.\r
+\r
+ 4. Redistribution. You may reproduce and distribute copies of the\r
+ Work or Derivative Works thereof in any medium, with or without\r
+ modifications, and in Source or Object form, provided that You\r
+ meet the following conditions:\r
+\r
+ (a) You must give any other recipients of the Work or\r
+ Derivative Works a copy of this License; and\r
+\r
+ (b) You must cause any modified files to carry prominent notices\r
+ stating that You changed the files; and\r
+\r
+ (c) You must retain, in the Source form of any Derivative Works\r
+ that You distribute, all copyright, patent, trademark, and\r
+ attribution notices from the Source form of the Work,\r
+ excluding those notices that do not pertain to any part of\r
+ the Derivative Works; and\r
+\r
+ (d) If the Work includes a "NOTICE" text file as part of its\r
+ distribution, then any Derivative Works that You distribute must\r
+ include a readable copy of the attribution notices contained\r
+ within such NOTICE file, excluding those notices that do not\r
+ pertain to any part of the Derivative Works, in at least one\r
+ of the following places: within a NOTICE text file distributed\r
+ as part of the Derivative Works; within the Source form or\r
+ documentation, if provided along with the Derivative Works; or,\r
+ within a display generated by the Derivative Works, if and\r
+ wherever such third-party notices normally appear. The contents\r
+ of the NOTICE file are for informational purposes only and\r
+ do not modify the License. You may add Your own attribution\r
+ notices within Derivative Works that You distribute, alongside\r
+ or as an addendum to the NOTICE text from the Work, provided\r
+ that such additional attribution notices cannot be construed\r
+ as modifying the License.\r
+\r
+ You may add Your own copyright statement to Your modifications and\r
+ may provide additional or different license terms and conditions\r
+ for use, reproduction, or distribution of Your modifications, or\r
+ for any such Derivative Works as a whole, provided Your use,\r
+ reproduction, and distribution of the Work otherwise complies with\r
+ the conditions stated in this License.\r
+\r
+ 5. Submission of Contributions. Unless You explicitly state otherwise,\r
+ any Contribution intentionally submitted for inclusion in the Work\r
+ by You to the Licensor shall be under the terms and conditions of\r
+ this License, without any additional terms or conditions.\r
+ Notwithstanding the above, nothing herein shall supersede or modify\r
+ the terms of any separate license agreement you may have executed\r
+ with Licensor regarding such Contributions.\r
+\r
+ 6. Trademarks. This License does not grant permission to use the trade\r
+ names, trademarks, service marks, or product names of the Licensor,\r
+ except as required for reasonable and customary use in describing the\r
+ origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+ 7. Disclaimer of Warranty. Unless required by applicable law or\r
+ agreed to in writing, Licensor provides the Work (and each\r
+ Contributor provides its Contributions) on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+ implied, including, without limitation, any warranties or conditions\r
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+ PARTICULAR PURPOSE. You are solely responsible for determining the\r
+ appropriateness of using or redistributing the Work and assume any\r
+ risks associated with Your exercise of permissions under this License.\r
+\r
+ 8. Limitation of Liability. In no event and under no legal theory,\r
+ whether in tort (including negligence), contract, or otherwise,\r
+ unless required by applicable law (such as deliberate and grossly\r
+ negligent acts) or agreed to in writing, shall any Contributor be\r
+ liable to You for damages, including any direct, indirect, special,\r
+ incidental, or consequential damages of any character arising as a\r
+ result of this License or out of the use or inability to use the\r
+ Work (including but not limited to damages for loss of goodwill,\r
+ work stoppage, computer failure or malfunction, or any and all\r
+ other commercial damages or losses), even if such Contributor\r
+ has been advised of the possibility of such damages.\r
+\r
+ 9. Accepting Warranty or Additional Liability. While redistributing\r
+ the Work or Derivative Works thereof, You may choose to offer,\r
+ and charge a fee for, acceptance of support, warranty, indemnity,\r
+ or other liability obligations and/or rights consistent with this\r
+ License. However, in accepting such obligations, You may act only\r
+ on Your own behalf and on Your sole responsibility, not on behalf\r
+ of any other Contributor, and only if You agree to indemnify,\r
+ defend, and hold each Contributor harmless for any liability\r
+ incurred by, or claims asserted against, such Contributor by reason\r
+ of your accepting any such warranty or additional liability.\r
+\r
+ END OF TERMS AND CONDITIONS\r
+\r
+ APPENDIX: How to apply the Apache License to your work.\r
+\r
+ To apply the Apache License to your work, attach the following\r
+ boilerplate notice, with the fields enclosed by brackets "[]"\r
+ replaced with your own identifying information. (Don't include\r
+ the brackets!) The text should be enclosed in the appropriate\r
+ comment syntax for the file format. We also recommend that a\r
+ file or class name and description of purpose be included on the\r
+ same "printed page" as the copyright notice for easier\r
+ identification within third-party archives.\r
+\r
+ Copyright [yyyy] [name of copyright owner]\r
+\r
+ Licensed under the Apache License, Version 2.0 (the "License");\r
+ you may not use this file except in compliance with the License.\r
+ You may obtain a copy of the License at\r
+\r
+ http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+ Unless required by applicable law or agreed to in writing, software\r
+ distributed under the License is distributed on an "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ See the License for the specific language governing permissions and\r
+ limitations under the License.\r
+\r
--- /dev/null
+
+STRING(REPLACE ";" " " EXTRA_CFLAGS "${PKGS_CFLAGS}")
+
+SET(REL_AGENT daemon-manager-release-agent)
+ADD_EXECUTABLE(${REL_AGENT} ${REL_AGENT}.c)
+TARGET_LINK_LIBRARIES(${REL_AGENT} ${PKGS_LDFLAGS})
+SET_TARGET_PROPERTIES(${REL_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+INSTALL(TARGETS ${REL_AGENT} DESTINATION bin)
+
+SET(LAUNCH_AGENT daemon-manager-launch-agent)
+ADD_EXECUTABLE(${LAUNCH_AGENT} ${LAUNCH_AGENT}.c)
+TARGET_LINK_LIBRARIES(${LAUNCH_AGENT} ${PKGS_LDFLAGS})
+SET_TARGET_PROPERTIES(${LAUNCH_AGENT} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+
+INSTALL(TARGETS ${LAUNCH_AGENT} DESTINATION bin)
--- /dev/null
+#include <glib.h>
+#include <gio/gio.h>
+#include <stdio.h>
+#include <stdarg.h>
+
+#define DAEMON_MANAGER_NAME "org.tizen.DaemonManager"
+#define DAEMON_MANAGER_PATH "/org/tizen/DaemonManager"
+#define DAEMON_MANAGER_INTERFACE "org.tizen.DaemonManager"
+
+#define METHOD_RELEASED "Start"
+
+#define BUS_TYPE G_BUS_TYPE_SYSTEM
+
+#define LOG_PATH "/tmp/dmlaunch.err"
+
+static void elog(const char *fmt, ...)
+{
+ FILE *fp;
+ va_list ap;
+
+ fp = fopen(LOG_PATH, "w+");
+ if (!fp)
+ return;
+
+ va_start(ap, fmt);
+ vfprintf(fp, fmt, ap);
+ va_end(ap);
+
+ fclose(fp);
+}
+
+int main(int argc, char *argv[])
+{
+ GError *err;
+ GDBusProxy *proxy = NULL;
+ GDBusConnection *conn = NULL;
+ GVariant *res = NULL;
+
+ if (argc < 2) {
+ elog("usage) %s path\n", argv[0]);
+ return 1;
+ }
+
+ g_type_init();
+
+ /* TODO: use private bus? */
+ err = NULL;
+ conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (!conn) {
+ elog("Connection failed: %s\n", err ? err->message : "");
+ goto err;
+ }
+
+ err = NULL;
+ proxy = g_dbus_proxy_new_sync(conn,
+ G_DBUS_PROXY_FLAGS_NONE,
+ NULL,
+ DAEMON_MANAGER_NAME,
+ DAEMON_MANAGER_PATH,
+ DAEMON_MANAGER_INTERFACE,
+ NULL,
+ &err);
+ if (!proxy) {
+ elog("Proxy new: %s\n", err ? err->message : "");
+ goto err;
+ }
+
+ err = NULL;
+ res = g_dbus_proxy_call_sync(proxy,
+ METHOD_RELEASED,
+ g_variant_new("(s)", argv[1]),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &err);
+ if (!res) {
+ elog("Call error: %s\n", err ? err->message : "");
+ goto err;
+ }
+
+err:
+ if (res)
+ g_variant_unref(res);
+
+ if (proxy)
+ g_object_unref(proxy);
+
+ if (conn)
+ g_object_unref(conn);
+
+ if (err) {
+ g_clear_error(&err);
+ return 1;
+ }
+
+ return 0;
+}
+
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include "app_sock.h"
+#include "aul_util.h"
+
+#define LOG_PATH "/tmp/dmlaunch.err"
+
+static void elog(const char *fmt, ...)
+{
+ FILE *fp;
+ va_list ap;
+
+ fp = fopen(LOG_PATH, "w+");
+ if (!fp)
+ return;
+
+ va_start(ap, fmt);
+ vfprintf(fp, fmt, ap);
+ va_end(ap);
+
+ fclose(fp);
+}
+
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+
+ elog("release agent : [%d:%s]\n", argc, argv[1]);
+
+ if (argc < 2) {
+ elog("usage) %s path\n", argv[0]);
+ return 1;
+ }
+
+ ret = __app_send_raw(AUL_UTIL_PID, APP_RELEASED, (unsigned char*)argv[1], strlen(argv[1]));
+
+ elog("release agent : %d\n", ret);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdlib.h>
+#include <glib.h>
+#include <aul.h>
+#include "aul_util.h"
+#include "simple_util.h"
+
+GSList *app_status_info_list = NULL;
+
+int _add_app_status_info_list(char *appid, int pid)
+{
+ GSList *iter = NULL;
+ app_status_info_t *info_t = NULL;
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+ if(pid == info_t->pid) {
+ return 0;
+ }
+ }
+
+ info_t = malloc(sizeof(app_status_info_t));
+ strncpy(info_t->appid, appid, MAX_PACKAGE_STR_SIZE-1);
+ info_t->status = STATUS_LAUNCHING;
+ info_t->pid = pid;
+ app_status_info_list = g_slist_append(app_status_info_list, info_t);
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+
+ _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+ }
+
+ return 0;
+}
+
+int _update_app_status_info_list(int pid, int status)
+{
+ GSList *iter = NULL;
+ app_status_info_t *info_t = NULL;
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+ if(pid == info_t->pid) {
+ info_t->status = status;
+ break;
+ }
+ }
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+
+ _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+ }
+
+ return 0;
+}
+
+int _remove_app_status_info_list(int pid)
+{
+ GSList *iter = NULL;
+ app_status_info_t *info_t = NULL;
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+ if(pid == info_t->pid) {
+ app_status_info_list = g_slist_remove(app_status_info_list, info_t);
+ free(info_t);
+ break;
+ }
+ }
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+
+ _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+ }
+
+ return 0;
+}
+
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <assert.h>
+#include <glib.h>
+#include <dirent.h>
+
+#include <pkgmgr-info.h>
+#include <vconf.h>
+#include "amd_config.h"
+#include "simple_util.h"
+#include "amd_appinfo.h"
+
+
+#define SERVICE_GROUP "Service"
+
+struct appinfomgr {
+ GHashTable *tbl; /* key is filename, value is struct appinfo */
+};
+
+enum _appinfo_idx {
+ _AI_FILE = 0, /* service filename */
+ _AI_NAME,
+ _AI_COMP,
+ _AI_EXEC,
+ _AI_TYPE,
+ _AI_ONBOOT,
+ _AI_RESTART,
+ _AI_MULTI,
+ _AI_HWACC,
+ _AI_MAX,
+};
+#define _AI_START _AI_NAME /* start index */
+
+struct appinfo_t {
+ char *name;
+ enum appinfo_type type;
+};
+
+static struct appinfo_t _appinfos[] = {
+ [_AI_NAME] = { "Name", AIT_NAME, },
+ [_AI_COMP] = { "Component", AIT_COMP, },
+ [_AI_EXEC] = { "Exec", AIT_EXEC, },
+ [_AI_TYPE] = { "PkgType", AIT_TYPE, },
+ [_AI_ONBOOT] = { "StartOnBoot", AIT_ONBOOT, },
+ [_AI_RESTART] = { "AutoRestart", AIT_RESTART, },
+ [_AI_MULTI] = { "Multiple", AIT_MULTI, },
+ [_AI_HWACC] = { "Hwacceleration", AIT_HWACC, },
+};
+
+struct appinfo {
+ char *val[_AI_MAX];
+};
+
+int gles = 1;
+
+static void _free_appinfo(gpointer data)
+{
+ struct appinfo *c = data;
+ int i;
+
+ if (!c)
+ return;
+
+ for (i = 0; i < sizeof(c->val)/sizeof(c->val[0]); i++)
+ free(c->val[i]);
+
+ free(c);
+}
+
+static void _fini(struct appinfomgr *cf)
+{
+ assert(cf);
+
+ g_hash_table_destroy(cf->tbl);
+ free(cf);
+}
+
+static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *data)
+{
+ struct appinfo *c;
+ struct appinfomgr *cf = (struct appinfomgr *)data;
+ gboolean r;
+ char *exec;
+ char *type;
+ char *appid;
+ bool multiple;
+ bool onboot;
+ bool restart;
+ pkgmgrinfo_app_hwacceleration hwacc;
+ pkgmgrinfo_app_component component;
+ int ret = -1;
+
+ if (!handle) {
+ _E("null app handle");
+ return -1;
+ }
+
+ ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
+ if (ret < 0) {
+ _E("fail to get appinfo");
+ return -1;
+ }
+
+ g_hash_table_remove(cf->tbl, appid);
+
+ c = calloc(1, sizeof(*c));
+ if (!c) {
+ _E("create appinfo: %s", strerror(errno));
+ return -1;
+ }
+
+ memset(c, 0, sizeof(struct appinfo));
+
+ c->val[_AI_FILE] = strdup(appid);
+ if (!c->val[_AI_FILE]) {
+ _E("create appinfo: %s", strerror(errno));
+ _free_appinfo(c);
+ return -1;
+ }
+
+ c->val[_AI_NAME] = strdup(appid); //TODO :
+
+ pkgmgrinfo_appinfo_get_component(handle, &component);
+ if(component == PMINFO_UI_APP) {
+ c->val[_AI_COMP] = strdup("ui"); //TODO :
+
+ r = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
+ if(multiple == true)
+ c->val[_AI_MULTI] = strdup("true");
+ else c->val[_AI_MULTI] = strdup("false");
+
+ if(gles == 0) {
+ c->val[_AI_HWACC] = strdup("NOT_USE");
+ } else {
+
+ r = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
+ if (hwacc == PMINFO_HWACCELERATION_USE_GL) {
+ c->val[_AI_HWACC] = strdup("USE");
+ } else if (hwacc == PMINFO_HWACCELERATION_USE_SYSTEM_SETTING) {
+ c->val[_AI_HWACC] = strdup("SYS");
+ } else {
+ c->val[_AI_HWACC] = strdup("NOT_USE");
+ }
+ }
+ } else {
+ c->val[_AI_COMP] = strdup("svc");
+
+ r = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
+ if(onboot == true)
+ c->val[_AI_ONBOOT] = strdup("true");
+ else c->val[_AI_ONBOOT] = strdup("false");
+
+ r = pkgmgrinfo_appinfo_is_autorestart(handle, &restart);
+ if(restart == true)
+ c->val[_AI_RESTART] = strdup("true");
+ else c->val[_AI_RESTART] = strdup("false");
+ }
+
+ r = pkgmgrinfo_appinfo_get_exec(handle, &exec);
+ c->val[_AI_EXEC] = strdup(exec);
+
+ r = pkgmgrinfo_appinfo_get_apptype(handle, &type);
+ if(strncmp(type, "capp", 4) == 0 ) {
+ c->val[_AI_TYPE] = strdup("rpm");
+ } else if (strncmp(type, "c++app", 6) == 0 || strncmp(type, "ospapp", 6) == 0) {
+ c->val[_AI_TYPE] = strdup("tpk");
+ } else if (strncmp(type, "webapp", 6) == 0) {
+ c->val[_AI_TYPE] = strdup("wgt");
+ }
+
+ _D("%s : %s : %s", c->val[_AI_FILE], c->val[_AI_COMP], c->val[_AI_TYPE]);
+
+ g_hash_table_insert(cf->tbl, c->val[_AI_FILE], c);
+
+ return 0;
+}
+
+static int __app_info_delete_handler (const pkgmgrinfo_appinfo_h handle, void *data)
+{
+ struct appinfomgr *cf = (struct appinfomgr *)data;
+ char *appid;
+
+ pkgmgrinfo_appinfo_get_appid(handle, &appid);
+
+ g_hash_table_remove(cf->tbl, appid);
+
+ return 0;
+}
+
+static int _read_pkg_info(struct appinfomgr *cf)
+{
+ int r;
+
+ r = pkgmgrinfo_appinfo_get_installed_list(__app_info_insert_handler, cf);
+
+ return 0;
+}
+
+static struct appinfomgr *_init()
+{
+ struct appinfomgr *cf;
+
+ cf = calloc(1, sizeof(*cf));
+ if (!cf) {
+ _E("appinfo init: %s", strerror(errno));
+ return NULL;
+ }
+
+ cf->tbl = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, _free_appinfo);
+
+ return cf;
+}
+
+static void __vconf_cb(keynode_t *key, void *data)
+{
+ char *noti_string;
+ char *type_string;
+ char *appid;
+ char *saveptr;
+ char *pkgname;
+ pkgmgrinfo_appinfo_h handle;
+ struct appinfomgr *cf = (struct appinfomgr *)data;
+ int ret;
+
+ noti_string = vconf_keynode_get_str(key);
+ if( noti_string == NULL ) {
+ return;
+ }
+
+ _D("noti_string : %s",noti_string);
+
+ type_string = strtok_r(noti_string, ":", &saveptr);
+ appid = strtok_r(NULL, ":", &saveptr);
+
+ if ( strncmp(type_string, "create", 6) == 0) {
+ ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
+ if(ret < 0) {
+ _E("pkgmgrinfo_appinfo_get_appinfo fail");
+ }
+
+ _D("appid : %s /handle : %x", appid, handle);
+
+ __app_info_insert_handler(handle, data);
+
+ pkgmgrinfo_appinfo_destroy_appinfo(handle);
+ } else if ( strncmp(type_string, "delete", 6) == 0) {
+ g_hash_table_remove(cf->tbl, appid);
+ }
+}
+
+int appinfo_init(struct appinfomgr **cf)
+{
+ struct appinfomgr *_cf;
+ int r;
+ FILE *fp;
+ char buf[4096];
+ char *tmp;
+
+ if (!cf) {
+ errno = EINVAL;
+ _E("appinfo init: %s", strerror(errno));
+ return -1;
+ }
+
+ fp = fopen("/proc/cmdline", "r");
+ r = fgets(buf, sizeof(buf), fp);
+ tmp = strstr(buf, "gles");
+ if(tmp != NULL) {
+ sscanf(tmp,"gles=%d", &gles);
+ }
+ fclose(fp);
+
+ _cf = _init();
+ if (!_cf)
+ return -1;
+
+ r = _read_pkg_info(_cf);
+ if (r == -1) {
+ _fini(_cf);
+ return -1;
+ }
+
+ r = vconf_notify_key_changed(VCONFKEY_MENUSCREEN_DESKTOP, __vconf_cb, _cf);
+
+ *cf = _cf;
+
+ return 0;
+}
+
+void appinfo_fini(struct appinfomgr **cf)
+{
+ if (!cf || !*cf)
+ return;
+
+ _fini(*cf);
+ *cf = NULL;
+}
+
+const struct appinfo *appinfo_insert(struct appinfomgr *cf, const char *pkg_name)
+{
+ int r;
+ pkgmgrinfo_pkginfo_h handle;
+
+ r = pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &handle);
+ r = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_insert_handler, cf);
+ r = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_insert_handler, cf);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+
+ return cf;
+}
+
+void appinfo_delete(struct appinfomgr *cf, const char *pkg_name)
+{
+ int r;
+ pkgmgrinfo_pkginfo_h handle;
+
+ r = pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &handle);
+ r = pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_delete_handler, cf);
+ r = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_delete_handler, cf);
+ pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
+}
+
+const struct appinfo *appinfo_find(struct appinfomgr *cf, const char *filename)
+{
+ if (!cf || !filename || !*filename) {
+ errno = EINVAL;
+ _E("appinfo find: %s", strerror(errno));
+ return NULL;
+ }
+
+ return g_hash_table_lookup(cf->tbl, FILENAME(filename));
+}
+
+const char *appinfo_get_value(const struct appinfo *c, enum appinfo_type type)
+{
+ enum _appinfo_idx i;
+
+ if (!c) {
+ errno = EINVAL;
+ _E("appinfo get value: %s", strerror(errno));
+ return NULL;
+ }
+
+ for (i = _AI_START; i < sizeof(_appinfos)/sizeof(_appinfos[0]); i++) {
+ if (type == _appinfos[i].type)
+ return c->val[i];
+ }
+
+ errno = ENOENT;
+ _E("appinfo get value: %s", strerror(errno));
+
+ return NULL;
+}
+
+const char *appinfo_get_filename(const struct appinfo *c)
+{
+ if (!c) {
+ errno = EINVAL;
+ _E("appinfo get filename: %s", strerror(errno));
+ return NULL;
+ }
+
+ return c->val[_AI_FILE];
+}
+
+struct _cbinfo {
+ appinfo_iter_callback cb;
+ void *cb_data;
+};
+
+static void _iter_cb(gpointer key, gpointer value, gpointer user_data)
+{
+ struct _cbinfo *cbi = user_data;
+
+ assert(cbi);
+
+ cbi->cb(cbi->cb_data, key, value);
+}
+
+void appinfo_foreach(struct appinfomgr *cf, appinfo_iter_callback cb, void *user_data)
+{
+ struct _cbinfo cbi;
+
+ if (!cf || !cb) {
+ errno = EINVAL;
+ _E("appinfo foreach: %s", strerror(errno));
+ return;
+ }
+
+ cbi.cb = cb;
+ cbi.cb_data = user_data;
+
+ g_hash_table_foreach(cf->tbl, _iter_cb, &cbi);
+}
+
+int appinfo_get_boolean(const struct appinfo *c, enum appinfo_type type)
+{
+ const char *v;
+
+ v = appinfo_get_value(c, type);
+ if (!v)
+ return -1;
+
+ if (!strcmp(v, "1") || !strcasecmp(v, "true"))
+ return 1;
+
+ if (!strcmp(v, "0") || !strcasecmp(v, "false"))
+ return 0;
+
+ errno = EFAULT;
+
+ return -1;
+}
+
--- /dev/null
+#ifndef __AUL_AMD_APPINFO_H_
+#define __AUL_AMD_APPINFO_H_
+
+struct appinfomgr;
+struct appinfo;
+
+enum appinfo_type {
+ AIT_NAME,
+ AIT_COMP,
+ AIT_EXEC,
+ AIT_TYPE,
+ AIT_ONBOOT, /* start on boot: boolean */
+ AIT_RESTART, /* auto restart: boolean */
+ AIT_MULTI,
+ AIT_HWACC,
+};
+
+int appinfo_init(struct appinfomgr **cf);
+void appinfo_fini(struct appinfomgr **cf);
+
+const struct appinfo *appinfo_insert(struct appinfomgr *cf, const char *filename);
+void appinfo_delete(struct appinfomgr *cf, const char *filename);
+
+const struct appinfo *appinfo_find(struct appinfomgr *cf, const char *filename);
+const char *appinfo_get_value(const struct appinfo *c, enum appinfo_type type);
+const char *appinfo_get_filename(const struct appinfo *c);
+int appinfo_get_boolean(const struct appinfo *c, enum appinfo_type type);
+
+typedef void (*appinfo_iter_callback)(void *user_data,
+ const char *filename, const struct appinfo *c);
+void appinfo_foreach(struct appinfomgr *cf, appinfo_iter_callback cb, void *user_data);
+
+#endif /* __AUL_AMD_APPINFO_H_ */
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <errno.h>
+#include <limits.h>
+#include <dirent.h>
+#include <mntent.h>
+
+
+#include "amd_config.h"
+#include "simple_util.h"
+#include "amd_cgutil.h"
+
+#define CFILE_RELEASE_AGENT "release_agent"
+#define CFILE_NOTIFY_ON_RELEASE "notify_on_release"
+#define CFILE_TASKS "tasks"
+
+#define DEFAULT_MODE 0755
+
+struct ctrl {
+ enum ctrl_type ctrl;
+ char *root; /* cginfo's mount_point + subsystem name */
+};
+
+struct cginfo {
+ int refcnt;
+ char *mount_point;
+ struct ctrl ctrls[CTRL_MAX];
+};
+
+enum {
+ _MNT_ROOT,
+ _MNT_MGR,
+ _MNT_CPU,
+ _MNT_MEM,
+ /* add type after adding mount information to mntinfos[] */
+};
+
+struct mntinfo {
+ char *source;
+ char *ftype; /* filesystem type */
+ unsigned long flags;
+ char *option;
+};
+
+static struct mntinfo mntinfos[] = {
+ [_MNT_ROOT] = {
+ "cgroup_root",
+ "tmpfs",
+ MS_NODEV | MS_NOSUID | MS_NOEXEC,
+ NULL,
+ },
+ [_MNT_MGR] = {
+ "daemon_mgr",
+ "cgroup",
+ MS_NODEV | MS_NOSUID | MS_NOEXEC,
+ "none,name=daemon_mgr",
+ },
+ [_MNT_CPU] = {
+ "cpuset",
+ "cgroup",
+ MS_NODEV | MS_NOSUID | MS_NOEXEC,
+ "cpuset",
+ },
+ [_MNT_MEM] = {
+ "memory",
+ "cgroup",
+ MS_NODEV | MS_NOSUID | MS_NOEXEC,
+ "memory",
+ },
+ /* TODO: add more */
+};
+
+struct ctrlinfo {
+ int mnt_type;
+ char *name;
+};
+
+static struct ctrlinfo ctrlinfos[] = {
+ [CTRL_MGR] = { _MNT_MGR, "mgr", },
+#if defined(USE_CGROUP_CPU)
+ [CTRL_CPU] = { _MNT_CPU, "cpuset", },
+#endif
+#if defined(USE_CGROUP_MEM)
+ [CTRL_MEM] = { _MNT_MEM, "memory", },
+#endif
+};
+
+static inline int _mount(const char *mount_point, struct mntinfo *mti)
+{
+ assert(mti);
+ return mount(mti->source, mount_point, mti->ftype, mti->flags,
+ mti->option);
+}
+
+static inline int _umount(const char *mount_point)
+{
+ return umount2(mount_point, MNT_DETACH);
+}
+
+static int _write_single(struct ctrl *ctr,
+ const char *group, const char *file, const char *str)
+{
+ FILE *fp;
+ char path[FILENAME_MAX];
+ int r;
+
+ assert(ctr);
+ assert(file);
+
+ if (!str)
+ str = "";
+
+ snprintf(path, sizeof(path), "%s/%s%s%s", ctr->root,
+ group ? : "", group ? "/" : "", file);
+ fp = fopen(path, "w");
+ if (!fp) {
+ _E("open: %s: %s", path, strerror(errno));
+ return -1;
+ }
+
+ r = fputs(str, fp);
+ if (r == EOF) {
+ _E("write: %s,%s: %s", path, str, strerror(errno));
+ r = -1;
+ } else {
+ r = 0;
+ }
+
+ fclose(fp);
+
+ return r;
+}
+
+/*
+static void _trunc_newline(char *buf, int sz)
+{
+ char *s;
+
+ assert(buf);
+ assert(sz > 0);
+
+ s = buf;
+ while (*s) {
+ if (*s == '\r' || *s == '\n') {
+ *s = '\0';
+ break;
+ }
+ s++;
+ }
+}
+
+static int _read_single(struct ctrl *ctr, const char *file, char *buf, int sz)
+{
+ FILE *fp;
+ char path[FILENAME_MAX];
+ char _buf[LINE_MAX];
+ char *r;
+
+ assert(ctr);
+ assert(file);
+ assert(buf);
+ assert(sz > 0);
+
+ snprintf(path, sizeof(path), "%s/%s", ctr->root, file);
+ fp = fopen(path, "r");
+ if (!fp) {
+ _E("open: %s: %s", path, strerror(errno));
+ return -1;
+ }
+
+ r = fgets(_buf, sizeof(_buf), fp);
+ if (r == NULL) {
+ _E("read: %s: %s", path, strerror(errno));
+ } else {
+ _trunc_newline(_buf, sizeof(_buf));
+ snprintf(buf, sz, "%s", _buf);
+ }
+
+ fclose(fp);
+
+ return r == NULL ? -1 : 0;
+}
+*/
+
+static int _destroy(struct cginfo *cg)
+{
+ int i;
+ int r;
+
+ for (i = 0; i < sizeof(cg->ctrls)/sizeof(cg->ctrls[0]); i++) {
+ struct ctrl *ctr = &cg->ctrls[i];
+
+ if (ctr->root) {
+ r = _umount(ctr->root);
+ if (r == -1) {
+ _E("unmount: %s: %s",
+ ctr->root, strerror(errno));
+ return -1;
+ }
+ free(ctr->root);
+ ctr->root = NULL;
+ }
+ }
+
+ if (cg->mount_point) {
+ r = _umount(cg->mount_point);
+ if (r == -1) {
+ _E("unmount: %s: %s",
+ cg->mount_point, strerror(errno));
+ return -1;
+ }
+ free(cg->mount_point);
+ }
+
+ free(cg);
+
+ return 0;
+}
+
+void cgutil_destroy(struct cginfo **cg)
+{
+ int r;
+
+ if (!cg || !*cg)
+ return;
+
+ (*cg)->refcnt--;
+
+ if ((*cg)->refcnt > 0)
+ return;
+
+ r = _destroy(*cg);
+ if (r == -1)
+ return;
+
+ *cg = NULL;
+}
+
+static int check_cgroup_mount(const char *mount_point)
+{
+ struct mntent* mnt;
+ const char* table = "/etc/mtab";
+ FILE* fp;
+ int r = -1;
+ fp = setmntent(table, "r");
+
+ if (!fp)
+ return r;
+
+ while (mnt=getmntent(fp)) {
+ if (strcmp(mount_point, mnt->mnt_dir) == 0) {
+ r = 0;
+ break;
+ }
+ }
+ endmntent(fp);
+ return r;
+}
+
+static int _mount_root(struct cginfo *cg, const char *mount_point)
+{
+ int r = 0;
+
+ if (check_cgroup_mount(mount_point) < 0)
+ r = _mount(mount_point, &mntinfos[_MNT_ROOT]);
+ if (r == -1) {
+ if (errno != EBUSY) {
+ _E("mount: %s: %s", mount_point, strerror(errno));
+ return -1;
+ }
+ _D("'%s' already mounted", mount_point);
+ }
+
+ cg->mount_point = strdup(mount_point);
+
+ return 0;
+}
+
+static int _init_ctrl(struct ctrl *ctr, struct cginfo *cg, enum ctrl_type ctrl)
+{
+ int r;
+ int mt;
+ char path[FILENAME_MAX];
+
+ assert(ctr);
+ assert(ctrl >= 0);
+ assert(ctrl < sizeof(ctrlinfos)/sizeof(ctrlinfos[0]));
+
+ mt = ctrlinfos[ctrl].mnt_type;
+ snprintf(path, sizeof(path), "%s/%s",
+ cg->mount_point, ctrlinfos[ctrl].name);
+
+ /* TODO: read /proc/cgroup and check the current type is enabled */
+
+ r = mkdir(path, DEFAULT_MODE);
+ if (r == -1) {
+ if (errno != EEXIST) {
+ _E("mkdir: %s: %s", path, strerror(errno));
+ return -1;
+ }
+ _D("'%s' exist", path);
+ }
+
+ r = _mount(path, &mntinfos[mt]);
+ if (r == -1) {
+ if (errno != EBUSY) {
+ _E("mount: %s: %s", path, strerror(errno));
+ rmdir(path);
+ return -1;
+ }
+ _D("'%s' already mounted", path);
+ }
+
+ ctr->ctrl = ctrl;
+ ctr->root = strdup(path);
+
+ return 0;
+}
+
+static int _set_release_agent(struct ctrl *ctr, const char *agent_path)
+{
+ int r;
+
+ r = access(agent_path, X_OK);
+ if (r == -1) {
+ _E("'%s' is not executable: %s",
+ agent_path, strerror(errno));
+ return -1;
+ }
+
+ r = _write_single(ctr, NULL, CFILE_RELEASE_AGENT, agent_path);
+ if (r == -1)
+ return -1;
+
+ r = _write_single(ctr, NULL, CFILE_NOTIFY_ON_RELEASE, "1");
+ if (r == -1)
+ return -1;
+
+ return 0;
+}
+
+struct cginfo *cgutil_ref(struct cginfo *cg)
+{
+ if (cg)
+ cg->refcnt++;
+
+ return cg;
+}
+
+static int _create(struct cginfo *cg,
+ const char *mount_point, const char *agent_path)
+{
+ int i;
+ int r;
+
+ r = _mount_root(cg, mount_point);
+ if (r == -1)
+ return -1;
+
+ for (i = 0; i < sizeof(cg->ctrls)/sizeof(cg->ctrls[0]); i++) {
+ r = _init_ctrl(&cg->ctrls[i], cg, i);
+ if (r == -1)
+ return -1;
+ }
+
+ r = _set_release_agent(&cg->ctrls[CTRL_MGR], agent_path);
+ if (r == -1)
+ return -1;
+
+ return 0;
+}
+
+int cgutil_create(const char *mount_point, const char *agent_path,
+ struct cginfo **cg)
+{
+ struct cginfo *_cg;
+ int r;
+
+ if (!mount_point || !*mount_point ||
+ !agent_path || !*agent_path || !cg) {
+ errno = EINVAL;
+ _E("cgutil create: %s", strerror(errno));
+ return -1;
+ }
+
+ _cg = calloc(1, sizeof(*_cg));
+ if (!_cg) {
+ _E("cgutil alloc: %s", strerror(errno));
+ return -1;
+ }
+
+ r = _create(_cg, mount_point, agent_path);
+ if (r == -1) {
+ _destroy(_cg);
+ return -1;
+ }
+
+ *cg = cgutil_ref(_cg);
+
+ return 0;
+}
+
+int cgutil_create_group(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group)
+{
+ int r;
+ struct ctrl *ctr;
+ char path[FILENAME_MAX];
+
+ assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+ if (!cg || !group || !*group) {
+ errno = EINVAL;
+ _E("cgutil create group: %s", strerror(errno));
+ return -1;
+ }
+
+ ctr = &cg->ctrls[ctrl];
+ assert(ctr);
+
+ snprintf(path, sizeof(path), "%s/%s", ctr->root, FILENAME(group));
+
+ r = mkdir(path, DEFAULT_MODE);
+ if (r == -1) {
+ _E("cgutil create group: mkdir: %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+int cgutil_remove_group(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group)
+{
+ int r;
+ struct ctrl *ctr;
+ char path[FILENAME_MAX];
+
+ assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+ if (!cg || !group || !*group) {
+ errno = EINVAL;
+ _E("cgutil remove group: %s", strerror(errno));
+ return -1;
+ }
+
+ ctr = &cg->ctrls[ctrl];
+ assert(ctr);
+
+ snprintf(path, sizeof(path), "%s/%s", ctr->root, FILENAME(group));
+
+ r = rmdir(path);
+ if (r == -1) {
+ _E("cgutil remove group: rmdir: %s", strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+int cgutil_exist_group(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group)
+{
+ int r;
+ struct ctrl *ctr;
+ char path[FILENAME_MAX];
+ struct stat st;
+
+ assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+ if (!cg || !group || !*group) {
+ errno = EINVAL;
+ _E("cgutil exist group: %s", strerror(errno));
+ return -1;
+ }
+
+ ctr = &cg->ctrls[ctrl];
+ assert(ctr);
+
+ snprintf(path, sizeof(path), "%s/%s", ctr->root, FILENAME(group));
+
+ r = stat(path, &st);
+ if (r == -1) {
+ if (errno == ENOENT)
+ return 0;
+
+ _E("cgutil exist group: %s", strerror(errno));
+ return -1;
+ }
+
+ /* stat() returns no error, then group exists */
+ return 1;
+}
+
+int cgutil_group_add_pid(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group, pid_t pid)
+{
+ int r;
+ struct ctrl *ctr;
+ char buf[32]; /* 32 is enough for ineger number */
+
+ assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+ /* PID 1 is init's PID */
+ if (!cg || !group || !*group || pid <= 1) {
+ errno = EINVAL;
+ _E("cgutil add pid: %s", strerror(errno));
+ return -1;
+ }
+
+ ctr = &cg->ctrls[ctrl];
+ assert(ctr);
+
+ snprintf(buf, sizeof(buf), "%d", pid);
+
+ r = _write_single(ctr, FILENAME(group), CFILE_TASKS, buf);
+ if (r == -1)
+ return -1;
+
+ return 0;
+}
+
+static int _foreach_pid(struct ctrl *ctr, const char *group,
+ cgutil_iter_pid_callback cb, void *user_data)
+{
+ int r;
+ FILE *fp;
+ char path[FILENAME_MAX];
+
+ assert(ctr);
+ assert(cb);
+
+ snprintf(path, sizeof(path), "%s/%s/%s",
+ ctr->root, FILENAME(group), CFILE_TASKS);
+ fp = fopen(path, "r");
+ if (!fp) {
+ _E("open: %s: %s", path, strerror(errno));
+ return -1;
+ }
+
+ while (!feof(fp)) {
+ unsigned long l;
+
+ r = fscanf(fp, "%lu", &l);
+ if (r != 1)
+ break;
+
+ r = cb(user_data, group, l);
+ if (r == -1)
+ break;
+ }
+
+ fclose(fp);
+
+ return 0;
+}
+
+int cgutil_group_foreach_pid(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group,
+ cgutil_iter_pid_callback cb, void *user_data)
+{
+ struct ctrl *ctr;
+
+ assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+ if (!cg || !group || !*group || !cb) {
+ errno = EINVAL;
+ _E("cgutil foreach pid: %s", strerror(errno));
+ return -1;
+ }
+
+ ctr = &cg->ctrls[ctrl];
+ assert(ctr);
+
+ return _foreach_pid(ctr, group, cb, user_data);
+}
+
+static int _foreach_group(struct ctrl *ctr,
+ cgutil_iter_group_callback cb, void *user_data)
+{
+ int r;
+ DIR *d;
+ struct dirent *de;
+
+ assert(ctr);
+ assert(cb);
+
+ d = opendir(ctr->root);
+ if (!d) {
+ _E("open: %s: %s", ctr->root, strerror(errno));
+ return -1;
+ }
+
+ for (de = readdir(d); de; de = readdir(d)) {
+ if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, ".."))
+ continue;
+
+ r = cb(user_data, de->d_name);
+ if (r == -1)
+ break;
+ }
+
+ closedir(d);
+
+ return 0;
+}
+
+int cgutil_foreach_group(struct cginfo *cg, enum ctrl_type ctrl,
+ cgutil_iter_group_callback cb, void *user_data)
+{
+ struct ctrl *ctr;
+
+ assert(ctrl >= 0 && ctrl < CTRL_MAX);
+
+ if (!cg || !cb) {
+ errno = EINVAL;
+ _E("cgutil foreach group: %s", strerror(errno));
+ return -1;
+ }
+
+ ctr = &cg->ctrls[ctrl];
+ assert(ctr);
+
+ return _foreach_group(ctr, cb, user_data);
+}
--- /dev/null
+
+#ifndef __AUL_AMD_CGROUP_UTIL_H__
+#define __AUL_AMD_CGROUP_UTIL_H__
+
+enum ctrl_type {
+ CTRL_MGR, /* for manager */
+#if defined(USE_CGROUP_CPU) /* not implemented */
+ CTRL_CPU, /* cpuset */
+#endif
+#if defined(USE_CGROUP_MEM) /* not implemented */
+ CTRL_MEM, /* memory */
+#endif
+ /* TODO: add more */
+ CTRL_MAX,
+};
+
+struct cginfo;
+
+int cgutil_create(const char *mount_point, const char *agent_path,
+ struct cginfo **cg);
+void cgutil_destroy(struct cginfo **cg);
+
+struct cginfo *cgutil_ref(struct cginfo *cg);
+#define cgutil_unref(cg) cgutil_destroy(cg)
+
+
+int cgutil_create_group(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group);
+int cgutil_remove_group(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group);
+int cgutil_exist_group(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group);
+
+typedef int (*cgutil_iter_group_callback)(void *user_data, const char *group);
+int cgutil_foreach_group(struct cginfo *cg, enum ctrl_type ctrl,
+ cgutil_iter_group_callback cb, void *user_data);
+
+
+int cgutil_group_add_pid(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group, pid_t pid);
+
+typedef int (*cgutil_iter_pid_callback)(void *user_data, const char *group,
+ pid_t pid);
+int cgutil_group_foreach_pid(struct cginfo *cg,
+ enum ctrl_type ctrl, const char *group,
+ cgutil_iter_pid_callback cb, void *user_data);
+
+#endif /* __AUL_AMD_CGROUP_UTIL_H__ */
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#define AMD_LOG
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <utilX.h>
+#include <Ecore.h>
+#include <Evas.h>
+#include <aul.h>
+#include <glib.h>
+
+#include "amd_config.h"
+#include "simple_util.h"
+#include "app_sock.h"
+
+static struct {
+ Evas_Object *win;
+ Ecore_Event_Handler *key_up;
+ Ecore_Event_Handler *key_down;
+} key_info = {
+ .win = NULL,
+ .key_up = NULL,
+ .key_down = NULL,
+};
+
+GSList *key_pid_list = NULL;
+
+static Eina_Bool __key_release_cb(void *data, int type, void *event);
+static Eina_Bool __key_press_cb(void *data, int type, void *event);
+
+static Eina_Bool __key_release_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Up *ev = event;
+ int ret;
+ GSList *entry;
+ int *pid_data;
+ bundle *kb;
+
+ _D("Released");
+
+ if (!ev) {
+ _D("Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ entry = key_pid_list;
+ if (entry && entry->data) {
+ pid_data = (int *) entry->data;
+
+ kb = bundle_create();
+ bundle_add(kb, AUL_K_MULTI_KEY, ev->keyname);
+ bundle_add(kb, AUL_K_MULTI_KEY_EVENT, AUL_V_KEY_RELEASED);
+
+ ret = app_send_cmd(*pid_data, APP_KEY_EVENT, kb);
+
+ bundle_free(kb);
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+
+static Eina_Bool __key_press_cb(void *data, int type, void *event)
+{
+ Evas_Event_Key_Down *ev = event;
+ int ret;
+ GSList *entry;
+ int *pid_data;
+ bundle *kb;
+
+ _D("Pressed");
+
+ if (!ev) {
+ _D("Invalid event object");
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ entry = key_pid_list;
+ if (entry && entry->data) {
+ pid_data = (int *) entry->data;
+
+ kb = bundle_create();
+ bundle_add(kb, AUL_K_MULTI_KEY, ev->keyname);
+ bundle_add(kb, AUL_K_MULTI_KEY_EVENT, AUL_V_KEY_PRESSED);
+
+ ret = app_send_cmd(*pid_data, APP_KEY_EVENT, kb);
+
+ bundle_free(kb);
+ }
+
+ return ECORE_CALLBACK_RENEW;
+}
+
+int _register_key_event(int pid)
+{
+ int *pid_data;
+ GSList *entry;
+
+ pid_data = malloc(sizeof(int));
+ *pid_data = pid;
+
+ key_pid_list = g_slist_prepend(key_pid_list, pid_data);
+
+ _D("===key stack===");
+
+ for (entry = key_pid_list; entry; entry = entry->next) {
+ if (entry->data) {
+ pid_data = (int *) entry->data;
+ _D("pid : %d",*pid_data);
+ }
+ }
+
+ return 0;
+}
+
+int _unregister_key_event(int pid)
+{
+ GSList *entry;
+ int *pid_data;
+
+ for (entry = key_pid_list; entry; entry = entry->next) {
+ if (entry->data) {
+ pid_data = (int *) entry->data;
+ if(pid == *pid_data) {
+ key_pid_list = g_slist_remove(key_pid_list, entry->data);
+ free(pid_data);
+ }
+ }
+ }
+
+ _D("===key stack===");
+
+ for (entry = key_pid_list; entry; entry = entry->next) {
+ if (entry->data) {
+ pid_data = (int *) entry->data;
+ _D("pid : %d",*pid_data);
+ }
+ }
+
+ return 0;
+}
+
+int _key_init()
+{
+ key_info.win = ecore_x_window_input_new(0, 0, 0, 1, 1);
+ if (!key_info.win) {
+ _D("Failed to create hidden window");
+ }
+
+ ecore_x_icccm_title_set(key_info.win, "acdaemon,key,receiver");
+ ecore_x_netwm_name_set(key_info.win, "acdaemon,key,receiver");
+ ecore_x_netwm_pid_set(key_info.win, getpid());
+
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PLAYCD, EXCLUSIVE_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_STOPCD, EXCLUSIVE_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PAUSECD, EXCLUSIVE_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_NEXTSONG, EXCLUSIVE_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_PREVIOUSSONG, EXCLUSIVE_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_REWIND, EXCLUSIVE_GRAB);
+ utilx_grab_key(ecore_x_display_get(), key_info.win, KEY_FASTFORWARD, EXCLUSIVE_GRAB);
+
+ key_info.key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, __key_release_cb, NULL);
+ if (!key_info.key_up) {
+ _D("Failed to register a key up event handler");
+ }
+
+ key_info.key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, __key_press_cb, NULL);
+ if (!key_info.key_down) {
+ _D("Failed to register a key down event handler");
+ }
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+#ifndef __AUL_AMD_KEY_H_
+#define __AUL_AMD_KEY_H_
+
+int _key_init(void);
+int _register_key_event(int pid);
+int _unregister_key_event(int pid);
+
+#endif
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <signal.h>
+#include <bundle.h>
+#include <aul.h>
+#include <glib.h>
+#include <app-checker-server.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <app2ext_interface.h>
+
+#include "amd_config.h"
+#include "amd_launch.h"
+#include "amd_appinfo.h"
+#include "amd_status.h"
+#include "app_sock.h"
+#include "simple_util.h"
+#include "amd_cgutil.h"
+
+
+#define TERM_WAIT_SEC 3
+#define INIT_PID 1
+
+struct appinfomgr *_laf;
+struct cginfo *_lcg;
+
+typedef struct {
+ char *pkg_name; /* package */
+ char *app_path; /* exec */
+ char *original_app_path; /* exec */
+ int multiple; /* x_slp_multiple */
+ char *pkg_type;
+} app_info_from_pkgmgr;
+
+static GList *_kill_list;
+
+struct ktimer {
+ pid_t pid;
+ char *group;
+ guint tid; /* timer ID */
+ struct cginfo *cg;
+};
+
+static void _prepare_exec(void)
+{
+ setsid();
+
+ signal(SIGINT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGCHLD, SIG_DFL);
+
+ /* TODO: do security job */
+ /* TODO: setuid */
+}
+
+static int _add_cgroup(struct cginfo *cg, const char *group, int pid)
+{
+ int r;
+
+ r = cgutil_exist_group(cg, CTRL_MGR, group);
+ if (r == -1) {
+ _E("exist check error: %s", strerror(errno));
+ return -1;
+ }
+
+ if (r == 0) { /* not exist */
+ r = cgutil_create_group(cg, CTRL_MGR, group);
+ if (r == -1) {
+ _E("create group error");
+ return -1;
+ }
+ }
+
+ r = cgutil_group_add_pid(cg, CTRL_MGR, group, pid);
+ if (r == -1) {
+ _E("add pid to group error");
+ cgutil_remove_group(cg, CTRL_MGR, group);
+ return -1;
+ }
+
+ return 0;
+}
+
+static char **__create_argc_argv(bundle * kb, int *margc)
+{
+ char **argv;
+ int argc;
+
+ argc = bundle_export_to_argv(kb, &argv);
+
+ *margc = argc;
+ return argv;
+}
+static void _do_exec(struct cginfo *cg, const char *cmd, const char *group, bundle *kb)
+{
+ gchar **argv;
+ gint argc;
+ char **b_argv;
+ int b_argc;
+ gboolean b;
+ int r;
+
+ r = _add_cgroup(cg, group, getpid());
+ if (r == -1)
+ return;
+
+ b = g_shell_parse_argv(cmd, &argc, &argv, NULL);
+
+ if (kb) {
+ b_argv = __create_argc_argv(kb, &b_argc);
+ b_argv[0] = strdup(argv[0]);
+ _prepare_exec();
+ execv(b_argv[0], b_argv);
+ }
+
+ if (b) {
+ _prepare_exec();
+ execv(argv[0], argv);
+ }
+
+ _E("exec error: %s", strerror(errno));
+ g_strfreev(argv);
+}
+
+int service_start(struct cginfo *cg, const char *group, const char *cmd, bundle *kb)
+{
+ int r;
+ pid_t p;
+
+ if (!cg || !group || !*group || !cmd || !*cmd) {
+ errno = EINVAL;
+ _E("service start: %s", strerror(errno));
+ return -1;
+ }
+
+ p = fork();
+ switch (p) {
+ case 0: /* child process */
+ _do_exec(cg, cmd, group, kb);
+ /* exec error */
+ exit(0);
+ break;
+ case -1:
+ _E("service start: fork: %s", strerror(errno));
+ r = -1;
+ break;
+ default: /* parent process */
+ _D("child process: %d", p);
+ r = p;
+ break;
+ }
+
+ return r;
+}
+
+int _start_srv(struct appinfo *ai, bundle *kb)
+{
+ int r;
+ const char *group;
+ const char *cmd;
+
+ group = appinfo_get_filename(ai);
+
+ cmd = appinfo_get_value(ai, AIT_EXEC);
+ if (!cmd) {
+ _E("start service: '%s' has no exec", group);
+ return -1;
+ }
+
+ r = service_start(_lcg, group, cmd, kb);
+ if (r == -1) {
+ _E("start service: '%s': failed", group);
+ return -1;
+ }
+
+ return 0;
+}
+
+static void _free_kt(struct ktimer *kt)
+{
+ if (!kt)
+ return;
+
+ cgutil_unref(&kt->cg);
+ free(kt->group);
+ free(kt);
+}
+
+static void _kill_pid(struct cginfo *cg, const char *group, pid_t pid)
+{
+ int r;
+
+ if (pid <= INIT_PID) /* block sending to all process or init */
+ return;
+
+ r = cgutil_exist_group(cg, CTRL_MGR, group);
+ if (r == -1) {
+ _E("send SIGKILL: exist: %s", strerror(errno));
+ return;
+ }
+ if (r == 0) {
+ _D("send SIGKILL: '%s' not exist", group);
+ return;
+ }
+
+ /* TODO: check pid exist in group */
+
+ r = kill(pid, 0);
+ if (r == -1) {
+ _D("send SIGKILL: pid %d not exist", pid);
+ return;
+ }
+
+ r = kill(pid, SIGKILL);
+ if (r == -1)
+ _E("send SIGKILL: %s", strerror(errno));
+}
+
+static gboolean _ktimer_cb(gpointer data)
+{
+ struct ktimer *kt = data;
+
+ _kill_pid(kt->cg, kt->group, kt->pid);
+ _kill_list = g_list_remove(_kill_list, kt);
+ _free_kt(kt);
+
+ return FALSE;
+}
+
+static void _add_list(struct cginfo *cg, const char *group, pid_t pid)
+{
+ struct ktimer *kt;
+
+ kt = calloc(1, sizeof(*kt));
+ if (!kt)
+ return;
+
+ kt->pid = pid;
+ kt->group = strdup(group);
+ if (!kt->group) {
+ free(kt);
+ return;
+ }
+
+ kt->cg = cgutil_ref(cg);
+ kt->tid = g_timeout_add_seconds(TERM_WAIT_SEC, _ktimer_cb, kt);
+
+ _kill_list = g_list_append(_kill_list, kt);
+}
+
+static inline void _del_list(GList *l)
+{
+ struct ktimer *kt;
+
+ if (!l)
+ return;
+
+ kt = l->data;
+
+ g_source_remove(kt->tid);
+ _free_kt(kt);
+ _kill_list = g_list_delete_link(_kill_list, l);
+}
+
+static int _kill_pid_cb(void *user_data, const char *group, pid_t pid)
+{
+ int r;
+
+ if (pid <= INIT_PID) /* block sending to all process or init */
+ return 0;
+
+ r = kill(pid, SIGTERM);
+ if (r == -1)
+ _E("send SIGTERM: %s", strerror(errno));
+
+ _add_list(user_data, group, pid);
+
+ return 0;
+}
+
+int service_stop(struct cginfo *cg, const char *group)
+{
+ if (!cg || !group || !*group) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return cgutil_group_foreach_pid(cg, CTRL_MGR, FILENAME(group),
+ _kill_pid_cb, cg);
+}
+
+void service_release(const char *group)
+{
+ GList *l;
+ GList *d;
+
+ if (!group || !*group)
+ return;
+
+ group = FILENAME(group);
+
+ d = NULL;
+ for (l = _kill_list; l; l = g_list_next(l)) {
+ struct ktimer *k = l->data;
+
+ _del_list(d);
+
+ if (k->group && !strcmp(k->group, group))
+ d = l;
+ }
+
+ _del_list(d);
+}
+
+int _send_to_sigkill(int pid)
+{
+ int pgid;
+
+ pgid = getpgid(pid);
+ if (pgid <= 1)
+ return -1;
+
+ if (killpg(pgid, SIGKILL) < 0)
+ return -1;
+
+ return 0;
+}
+int _resume_app(int pid)
+{
+ int dummy;
+ int ret;
+ if ((ret =
+ __app_send_raw(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
+ sizeof(int))) < 0) {
+ if (ret == -EAGAIN)
+ _E("resume packet timeout error");
+ else {
+ _E("raise failed - %d resume fail\n", pid);
+ _E("we will term the app - %d\n", pid);
+ _send_to_sigkill(pid);
+ ret = -1;
+ }
+ }
+ _D("resume done\n");
+ return ret;
+}
+
+int _term_app(int pid)
+{
+ int dummy;
+ if (__app_send_raw
+ (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int)) < 0) {
+ _D("terminate packet send error - use SIGKILL");
+ if (_send_to_sigkill(pid) < 0) {
+ _E("fail to killing - %d\n", pid);
+ return -1;
+ }
+ }
+ _D("term done\n");
+ return 0;
+}
+
+int _fake_launch_app(int cmd, int pid, bundle * kb)
+{
+ int datalen;
+ int ret;
+ bundle_raw *kb_data;
+
+ bundle_encode(kb, &kb_data, &datalen);
+ if ((ret = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
+ _E("error request fake launch - error code = %d", ret);
+ free(kb_data);
+ return ret;
+}
+
+static int __nofork_processing(int cmd, int pid, bundle * kb)
+{
+ int ret = -1;
+ switch (cmd) {
+ case APP_OPEN:
+ case APP_RESUME:
+ _D("resume app's pid : %d\n", pid);
+ if ((ret = _resume_app(pid)) < 0)
+ _E("__resume_app failed. error code = %d", ret);
+ _D("resume app done");
+ break;
+
+ case APP_START:
+ case APP_START_RES:
+ _D("fake launch pid : %d\n", pid);
+ if ((ret = _fake_launch_app(cmd, pid, kb)) < 0)
+ _E("fake_launch failed. error code = %d", ret);
+ _D("fake launch done");
+ break;
+ }
+ return ret;
+}
+
+static void __real_send(int clifd, int ret)
+{
+ if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
+ if (errno == EPIPE) {
+ _E("send failed due to EPIPE.\n");
+ }
+ _E("send fail to client");
+ }
+
+ close(clifd);
+}
+
+int __sat_ui_is_running()
+{
+ char *apppath = "/usr/apps/org.tizen.sat-ui/bin/sat-ui";
+ int ret = 0;
+
+ ret = __proc_iter_cmdline(NULL, apppath);
+
+ return ret;
+}
+
+int __sat_ui_launch(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
+{
+ int ret = -1;
+ char *app_path = "/usr/apps/org.tizen.sat-ui/bin/sat-ui KEY_EXEC_TYPE 0";
+ int pid = -1;
+ char tmp_pid[MAX_PID_STR_BUFSZ];
+
+ snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", caller_pid);
+ bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
+
+ pid = __sat_ui_is_running();
+
+ if (pid > 0) {
+ if (caller_pid == pid) {
+ _D("caller process & callee process is same.[%s:%d]", appid, pid);
+ pid = -ELOCALLAUNCH_ID;
+ } else if ((ret = __nofork_processing(cmd, pid, kb)) < 0) {
+ pid = ret;
+ }
+ } else if (cmd != APP_RESUME) {
+ bundle_add(kb, AUL_K_HWACC, "NOT_USE");
+ bundle_add(kb, AUL_K_EXEC, app_path);
+ bundle_add(kb, AUL_K_PACKAGETYPE, "rpm");
+ pid = app_send_cmd(LAUNCHPAD_PID, cmd, kb);
+ }
+
+ __real_send(fd, pid);
+
+ if(pid > 0) {
+ //_status_add_app_info_list(appid, app_path, pid);
+ ac_server_check_launch_privilege(appid, "rpm", pid);
+ }
+
+ return pid;
+}
+
+int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, int fd)
+{
+ struct appinfo *ai;
+ int ret = -1;
+ char *componet = NULL;
+ char *multiple = NULL;
+ char *app_path = NULL;
+ char *pkg_type = NULL;
+ int pid = -1;
+ char tmp_pid[MAX_PID_STR_BUFSZ];
+ char *hwacc;
+
+ int location = -1;
+ app2ext_handle *app2_handle = NULL;
+
+ if(strncmp(appid, "org.tizen.sat-ui", 18) == 0) {
+ pid = __sat_ui_launch(appid, kb, cmd, caller_pid, fd);
+ return pid;
+ }
+
+ snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", caller_pid);
+ bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
+
+ if (cmd == APP_START_RES)
+ bundle_add(kb, AUL_K_WAIT_RESULT, "1");
+
+ ai = appinfo_find(_laf, appid);
+
+ componet = appinfo_get_value(ai, AIT_COMP);
+ app_path = appinfo_get_value(ai, AIT_EXEC);
+ pkg_type = appinfo_get_value(ai, AIT_TYPE);
+ if (componet && strncmp(componet, "ui", 2) == 0) {
+ multiple = appinfo_get_value(ai, AIT_MULTI);
+ if (!multiple || strncmp(multiple, "false", 5) == 0) {
+ pid = _status_app_is_running_v2(appid);
+ }
+
+ if (pid > 0) {
+ if (caller_pid == pid) {
+ _D("caller process & callee process is same.[%s:%d]", appid, pid);
+ pid = -ELOCALLAUNCH_ID;
+ } else if ((ret = __nofork_processing(cmd, pid, kb)) < 0) {
+ pid = ret;
+ }
+ } else if (cmd != APP_RESUME) {
+ hwacc = appinfo_get_value(ai, AIT_HWACC);
+ bundle_add(kb, AUL_K_HWACC, hwacc);
+ bundle_add(kb, AUL_K_EXEC, app_path);
+ bundle_add(kb, AUL_K_PACKAGETYPE, pkg_type);
+ if(strncmp(pkg_type, "wgt", 3) == 0) {
+ pid = app_send_cmd(WEB_LAUNCHPAD_PID, cmd, kb);
+ } else {
+ pid = app_send_cmd(LAUNCHPAD_PID, cmd, kb);
+ }
+ //_add_cgroup(_lcg, appid, pid);
+ }
+ } else if (componet && strncmp(componet, "svc", 3) == 0) {
+ pid = _status_app_is_running_v2(appid);
+ if (pid > 0) {
+ if ((ret = __nofork_processing(cmd, pid, kb)) < 0) {
+ pid = ret;
+ }
+ } else if (cmd != APP_RESUME) {
+ pid = service_start(_lcg, appid, app_path, kb);
+ }
+ } else {
+ _E("unkown application");
+ }
+
+ location = app2ext_get_app_location(appid);
+ if (location == APP2EXT_SD_CARD)
+ {
+ app2_handle = app2ext_init(APP2EXT_SD_CARD);
+ if (app2_handle == NULL) {
+ _E("app2_handle : app2ext init failed\n");
+ return -1;
+ }
+
+ ret = app2_handle->interface.enable(appid);
+ if (ret) {
+ _E("app2_handle : app enable API fail Reason %d", ret);
+ }
+
+ app2ext_deinit(app2_handle);
+ }
+
+ __real_send(fd, pid);
+
+ if(pid > 0) {
+ //_status_add_app_info_list(appid, app_path, pid);
+ ret = ac_server_check_launch_privilege(appid, appinfo_get_value(ai, AIT_TYPE), pid);
+ return ret != AC_R_ERROR ? pid : -1;
+ }
+
+ return pid;
+}
+
+
+int _launch_init(struct amdmgr* amd)
+{
+ _laf = amd->af;
+ _lcg = amd->cg;
+
+ return 0;
+}
+
+
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+#ifndef __AUL_AMD_LAUNCH_H_
+#define __AUL_AMD_LAUNCH_H_
+
+#include <bundle.h>
+#include "aul_util.h"
+#include "amd_appinfo.h"
+
+int _send_to_sigkill(int pid);
+int _resume_app(int pid);
+int _term_app(int pid);
+int _fake_launch_app(int cmd, int pid, bundle * kb);
+int _start_app(char* appid, bundle* kb, int cmd, int caller_pid, int fd);
+void service_release(const char *group);
+int _start_srv(struct appinfo *ai, bundle *kb);
+
+int _launch_init(struct amdmgr* amd);
+
+#endif /* __AUL_AMD_LAUNCH_H_ */
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <Ecore_X.h>
+#include <Ecore_Input.h>
+#include <utilX.h>
+#include <Ecore.h>
+#include <Evas.h>
+#include <aul.h>
+#include <vconf.h>
+#include <app-checker-server.h>
+#include <ail.h>
+#include <glib.h>
+
+#include "amd_config.h"
+#include "simple_util.h"
+#include "aul_util.h"
+#include "amd_appinfo.h"
+#include "amd_cgutil.h"
+#include "amd_key.h"
+#include "amd_status.h"
+#include "amd_launch.h"
+
+#ifndef MOUNT_PATH
+# define MOUNT_PATH "/sys/fs/cgroup"
+#endif
+
+#ifndef AGENT_PATH
+# define AGENT_PATH "/usr/bin/daemon-manager-release-agent"
+#endif
+
+typedef struct _r_app_info_t{
+ char pkg_name[MAX_PACKAGE_STR_SIZE];
+ int pid;
+} r_app_info_t;
+
+GSList *r_app_info_list = NULL;
+
+static void __vconf_cb(keynode_t *key, void *data);
+static int __app_dead_handler(int pid, void *data);
+static int __init();
+
+static int __send_to_sigkill(int pid)
+{
+ int pgid;
+
+ pgid = getpgid(pid);
+ if (pgid <= 1)
+ return -1;
+
+ if (killpg(pgid, SIGKILL) < 0)
+ return -1;
+
+ return 0;
+}
+
+static int __kill_bg_apps(int limit)
+{
+ int len;
+ int i;
+ int n;
+ r_app_info_t *info_t = NULL;
+ GSList *iter = NULL;
+
+ len = g_slist_length(r_app_info_list);
+
+ n = len - limit;
+
+ if (n<=0) return 0;
+
+ for ( i=0, iter = r_app_info_list; i<n ; i++) {
+ info_t = (r_app_info_t *)iter->data;
+ __send_to_sigkill(info_t->pid);
+ iter = g_slist_next(iter);
+ r_app_info_list = g_slist_remove(r_app_info_list, info_t);
+ free(info_t);
+ }
+
+ return 0;
+}
+
+static int __remove_item_running_list(int pid)
+{
+ r_app_info_t *info_t = NULL;
+ GSList *iter = NULL;
+
+ for (iter = r_app_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (r_app_info_t *)iter->data;
+ if(pid == info_t->pid) {
+ r_app_info_list = g_slist_remove(r_app_info_list, info_t);
+ free(info_t);
+ break;
+ }
+ }
+ return 0;
+}
+
+gboolean __add_item_running_list(gpointer user_data)
+{
+ bool taskmanage;
+ ail_appinfo_h handle = NULL;
+ ail_error_e ail_ret;
+ r_app_info_t *info_t = NULL;
+ GSList *iter = NULL;
+ int found = 0;
+ int limit;
+ int ret;
+ char *pkgname;
+ int pid;
+
+ item_pkt_t *item;
+
+ item = (item_pkt_t *)user_data;
+
+ pkgname = item->appid;
+ pid = item->pid;
+
+ ret = vconf_get_int(VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS, &limit);
+
+ if (pkgname == NULL) {
+ return false;
+ } else if (strncmp(pkgname, "org.tizen.cluster-home", 24) == 0) {
+ if(limit>0) __kill_bg_apps(limit-1);
+ return false;
+ }
+
+ ail_ret = ail_package_get_appinfo(pkgname, &handle);
+ if (ail_ret != AIL_ERROR_OK) {
+ _E("ail_get_appinfo with %s failed", pkgname);
+ return false;
+ }
+
+ ail_ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &taskmanage);
+ if (ail_ret != AIL_ERROR_OK) {
+ _E("ail_appinfo_get_bool failed");
+ goto END;
+ }
+
+ if (taskmanage == false)
+ goto END;
+
+ for (iter = r_app_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (r_app_info_t *)iter->data;
+ if(pid == info_t->pid) {
+ found = 1;
+ r_app_info_list = g_slist_remove(r_app_info_list, info_t);
+ r_app_info_list = g_slist_append(r_app_info_list, info_t);
+ break;
+ }
+ }
+ if(found == 0) {
+ info_t = malloc(sizeof(r_app_info_t));
+ strncpy(info_t->pkg_name, pkgname, MAX_PACKAGE_STR_SIZE-1);
+ info_t->pid = pid;
+ r_app_info_list = g_slist_append(r_app_info_list, info_t);
+ }
+
+ for (iter = r_app_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (r_app_info_t *)iter->data;
+ }
+
+ if(limit>0) __kill_bg_apps(limit);
+
+ for (iter = r_app_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (r_app_info_t *)iter->data;
+ }
+
+END:
+ if (ail_destroy_appinfo(handle) != AIL_ERROR_OK)
+ _E("ail_destroy_rs failed");
+
+ free(item);
+ return false;
+}
+
+static void __vconf_cb(keynode_t *key, void *data)
+{
+ int limit;
+ const char *name;
+
+ name = vconf_keynode_get_name(key);
+ if( name == NULL ) {
+ return;
+ } else if ( strcmp(name, VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS) != 0)
+ {
+ return;
+ }
+
+ limit = vconf_keynode_get_int(key);
+ if(limit>0) __kill_bg_apps(limit);
+}
+
+static int __app_dead_handler(int pid, void *data)
+{
+ int ret;
+
+ ret = _unregister_key_event(pid);
+ ret = __remove_item_running_list(pid);
+ ret = _status_remove_app_info_list(pid);
+
+ return 0;
+}
+
+static void __start_cb(void *user_data,
+ const char *filename, const struct appinfo *ai)
+{
+ struct amdmgr *amd = user_data;
+ char *componet = NULL;
+ int r;
+
+ componet = appinfo_get_value(ai, AIT_COMP);
+
+ r = appinfo_get_boolean(ai, AIT_ONBOOT);
+ if (r == 1 && strncmp(componet, "svc", 3) == 0)
+ _start_srv(ai, NULL);
+}
+
+static void _start_services(struct amdmgr *amd)
+{
+ appinfo_foreach(amd->af, __start_cb, amd);
+}
+
+static int __init()
+{
+ int r;
+ struct amdmgr amd;
+
+ ecore_init();
+ evas_init();
+ ecore_event_init();
+ ecore_x_init(NULL);
+
+ appinfo_init(&amd.af);
+ cgutil_create(MOUNT_PATH, AGENT_PATH, &amd.cg);
+ _requset_init(&amd);
+ _launch_init(&amd);
+ _status_init(&amd);
+
+#ifndef __i386__
+ _key_init();
+#endif
+
+ r = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVOPTION_BGPROCESS, __vconf_cb, NULL);
+ aul_listen_app_dead_signal(__app_dead_handler, NULL);
+
+ _start_services(&amd);
+
+ return 0;
+}
+
+gboolean __amd_ready(gpointer user_data)
+{
+ int handle;
+
+ handle = creat("/tmp/amd_ready", S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH);
+ if (handle != -1)
+ close(handle);
+
+ return FALSE;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret;
+
+ ret = ac_server_initialize();
+ ret = __init();
+
+ g_idle_add(__amd_ready, NULL);
+
+ ecore_main_loop_begin();
+
+ return 0;
+}
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <poll.h>
+#include <aul.h>
+#include <glib.h>
+#include <bundle.h>
+#include <rua.h>
+
+#include "amd_config.h"
+#include "simple_util.h"
+#include "app_sock.h"
+#include "aul_util.h"
+#include "amd_request.h"
+#include "amd_key.h"
+#include "amd_launch.h"
+#include "amd_appinfo.h"
+#include "amd_cgutil.h"
+#include "amd_status.h"
+
+
+#define INHOUSE_UID 5000
+
+struct appinfomgr *_raf;
+struct cginfo *_rcg;
+
+static int __send_result_to_client(int fd, int res);
+static gboolean __request_handler(gpointer data);
+
+static int __send_result_to_client(int fd, int res)
+{
+ if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {
+ if (errno == EPIPE)
+ _E("send failed due to EPIPE.\n");
+ _E("send fail to client");
+ }
+ close(fd);
+ return 0;
+}
+
+static void __real_send(int clifd, int ret)
+{
+ if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
+ if (errno == EPIPE) {
+ _E("send failed due to EPIPE.\n");
+ }
+ _E("send fail to client");
+ }
+
+ close(clifd);
+}
+
+static int __get_caller_pid(bundle *kb)
+{
+ const char *pid_str;
+ int pid;
+
+ pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID);
+ if(pid_str)
+ goto end;
+
+ pid_str = bundle_get_val(kb, AUL_K_CALLER_PID);
+ if (pid_str == NULL)
+ return -1;
+
+end:
+ pid = atoi(pid_str);
+ if (pid <= 1)
+ return -1;
+
+ return pid;
+}
+
+static int __foward_cmd(int cmd, bundle *kb, int cr_pid)
+{
+ int pid;
+ char tmp_pid[MAX_PID_STR_BUFSZ];
+ int datalen;
+ bundle_raw *kb_data;
+ int res;
+
+ if ((pid = __get_caller_pid(kb)) < 0)
+ return AUL_R_ERROR;
+
+ snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", cr_pid);
+
+ bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
+
+ bundle_encode(kb, &kb_data, &datalen);
+ if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
+ res = AUL_R_ERROR;
+
+ free(kb_data);
+
+ return res;
+}
+
+static int __app_process_by_pid(int cmd,
+ const char *pkg_name, struct ucred *cr)
+{
+ int pid;
+ int ret = -1;
+
+ if (pkg_name == NULL)
+ return -1;
+
+ if ((cr->uid != 0) && (cr->uid != INHOUSE_UID)) {
+ _E("reject by security rule, your uid is %u\n", cr->uid);
+ return -1;
+ }
+
+ pid = atoi(pkg_name);
+ if (pid <= 1) {
+ _E("invalid pid");
+ return -1;
+ }
+
+ switch (cmd) {
+ case APP_RESUME_BY_PID:
+ ret = _resume_app(pid);
+ break;
+ case APP_TERM_BY_PID:
+ ret = _term_app(pid);
+ break;
+ case APP_KILL_BY_PID:
+ if ((ret = _send_to_sigkill(pid)) < 0)
+ _E("fail to killing - %d\n", pid);
+ }
+
+ return ret;
+}
+
+static gboolean __add_history_handler(gpointer user_data)
+{
+ struct rua_rec rec;
+ int ret;
+ bundle *kb = NULL;
+ char *appid = NULL;
+ char *app_path = NULL;
+ struct appinfo *ai;
+ app_pkt_t *pkt = (app_pkt_t *)user_data;
+
+ if (!pkt)
+ return FALSE;
+
+ kb = bundle_decode(pkt->data, pkt->len);
+ appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
+
+ if(strncmp(appid, "org.tizen.sat-ui", 18) == 0) {
+ app_path = "/usr/apps/org.tizen.sat-ui/bin/sat-ui KEY_EXEC_TYPE 0";
+ } else {
+ ai = (struct appinfo *)appinfo_find(_raf, appid);
+ app_path = (char *)appinfo_get_value(ai, AIT_EXEC);
+ }
+
+ memset((void *)&rec, 0, sizeof(rec));
+
+ rec.pkg_name = appid;
+ rec.app_path = app_path;
+
+ if(pkt->len > 0) {
+ rec.arg = (char *)pkt->data;
+ }
+
+ _D("add rua history %s %s", rec.pkg_name, rec.app_path);
+
+ ret = rua_add_history(&rec);
+ if (ret == -1)
+ _D("rua add history error");
+
+ if (kb != NULL)
+ bundle_free(kb);
+ free(pkt);
+
+ return FALSE;
+}
+
+static int __get_pid_cb(void *user_data, const char *group, pid_t pid)
+{
+ int *sz = user_data;
+
+ _D("%s: %d : %d", *sz, pid);
+ *sz = 1; /* 1 is enough */
+
+ return -1; /* stop the iteration */
+}
+
+static int __releasable(const char *filename)
+{
+ int sz;
+ int r;
+
+ if (!filename || !*filename) {
+ _E("release service: name is empty");
+ return -1;
+ }
+
+ r = cgutil_exist_group(_rcg, CTRL_MGR, filename);
+ if (r == -1) {
+ _E("release service: exist: %s", strerror(errno));
+ return -1;
+ }
+ if (r == 0) {
+ _E("release service: '%s' already not exist", filename);
+ return -1;
+ }
+
+ sz = 0;
+ r = cgutil_group_foreach_pid(_rcg, CTRL_MGR, filename,
+ __get_pid_cb, &sz);
+ if (r == -1) {
+ _E("release service: '%s' read pid error", filename);
+ return -1;
+ }
+ if (sz > 0) {
+ _E("release service: '%s' group has process", filename);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int __release_srv(const char *filename)
+{
+ int r;
+ struct appinfo *ai;
+
+ r = __releasable(filename);
+ if (r == -1)
+ return -1;
+
+ ai = (struct appinfo *)appinfo_find(_raf, filename);
+ if (!ai) {
+ _E("release service: '%s' not found", filename);
+ return -1;
+ }
+
+ r = appinfo_get_boolean(ai, AIT_RESTART);
+ if (r == 1) {
+ /* Auto restart */
+ _D("Auto restart set: '%s'", filename);
+ return _start_srv(ai, NULL);
+ }
+
+ service_release(filename);
+
+ r = cgutil_remove_group(_rcg, CTRL_MGR, filename);
+ if (r == -1) {
+ _E("'%s' group remove error: %s", filename, strerror(errno));
+ return -1;
+ }
+
+ return 0;
+}
+
+static gboolean __request_handler(gpointer data)
+{
+ GPollFD *gpollfd = (GPollFD *) data;
+ int fd = gpollfd->fd;
+ app_pkt_t *pkt;
+ int clifd;
+ struct ucred cr;
+ int *status;
+ int ret = -1;
+ int free_pkt = 1;
+ char *appid;
+ char *app_path;
+ char *tmp_pid;
+ int pid;
+ bundle *kb = NULL;
+ item_pkt_t *item;
+
+ if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
+ _E("recv error");
+ return FALSE;
+ }
+
+ switch (pkt->cmd) {
+ case APP_OPEN:
+ case APP_RESUME:
+ case APP_START:
+ case APP_START_RES:
+ kb = bundle_decode(pkt->data, pkt->len);
+ appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
+ ret = _start_app(appid, kb, pkt->cmd, cr.pid, clifd);
+
+ if (kb != NULL)
+ bundle_free(kb), kb = NULL;
+
+ if(ret > 0) {
+ item = calloc(1, sizeof(item_pkt_t));
+ item->pid = ret;
+ strncpy(item->appid, appid, 511);
+ free_pkt = 0;
+
+ g_timeout_add(1000, __add_history_handler, pkt);
+ g_timeout_add(1200, __add_item_running_list, item);
+ }
+ break;
+ case APP_RESULT:
+ case APP_CANCEL:
+ kb = bundle_decode(pkt->data, pkt->len);
+ ret = __foward_cmd(pkt->cmd, kb, cr.pid);
+ __real_send(clifd, ret);
+ break;
+ case APP_TERM_BY_PID:
+ case APP_RESUME_BY_PID:
+ case APP_KILL_BY_PID:
+ kb = bundle_decode(pkt->data, pkt->len);
+ appid = (char *)bundle_get_val(kb, AUL_K_PKG_NAME);
+ ret = __app_process_by_pid(pkt->cmd, appid, &cr);
+ __real_send(clifd, ret);
+ break;
+ case APP_RUNNING_INFO:
+ _status_send_running_appinfo_v2(clifd);
+ break;
+ case APP_IS_RUNNING:
+ appid = malloc(MAX_PACKAGE_STR_SIZE);
+ strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
+ ret = _status_app_is_running_v2(appid);
+ _D("APP_IS_RUNNING : %s : %d",appid, ret);
+ __send_result_to_client(clifd, ret);
+ free(appid);
+ break;
+ case APP_KEY_RESERVE:
+ ret = _register_key_event(cr.pid);
+ __send_result_to_client(clifd, ret);
+ break;
+ case APP_KEY_RELEASE:
+ ret = _unregister_key_event(cr.pid);
+ __send_result_to_client(clifd, ret);
+ break;
+ case APP_STATUS_UPDATE:
+ status = (int *)pkt->data;
+ ret = _status_update_app_info_list(cr.pid, *status);
+ __send_result_to_client(clifd, ret);
+ break;
+ case APP_RELEASED:
+ appid = malloc(MAX_PACKAGE_STR_SIZE);
+ strncpy(appid, (const char*)pkt->data, MAX_PACKAGE_STR_SIZE-1);
+ ret = __release_srv(appid);
+ __send_result_to_client(clifd, ret);
+ free(appid);
+ break;
+ case APP_RUNNING_LIST_UPDATE:
+ /*kb = bundle_decode(pkt->data, pkt->len);
+ appid = (char *)bundle_get_val(kb, AUL_K_APPID);
+ app_path = (char *)bundle_get_val(kb, AUL_K_EXEC);
+ tmp_pid = (char *)bundle_get_val(kb, AUL_K_PID);
+ pid = atoi(tmp_pid);
+ ret = _status_add_app_info_list(appid, app_path, pid);*/
+ ret = 0;
+ __send_result_to_client(clifd, ret);
+ break;
+ default:
+ _E("no support packet");
+ }
+
+ if (free_pkt)
+ free(pkt);
+
+ if (kb != NULL)
+ bundle_free(kb), kb = NULL;
+
+ return TRUE;
+}
+
+static gboolean __au_glib_check(GSource *src)
+{
+ GSList *fd_list;
+ GPollFD *tmp;
+
+ fd_list = src->poll_fds;
+ do {
+ tmp = (GPollFD *) fd_list->data;
+ if ((tmp->revents & (POLLIN | POLLPRI)))
+ return TRUE;
+ fd_list = fd_list->next;
+ } while (fd_list);
+
+ return FALSE;
+}
+
+static gboolean __au_glib_dispatch(GSource *src, GSourceFunc callback,
+ gpointer data)
+{
+ callback(data);
+ return TRUE;
+}
+
+static gboolean __au_glib_prepare(GSource *src, gint *timeout)
+{
+ return FALSE;
+}
+
+static GSourceFuncs funcs = {
+ .prepare = __au_glib_prepare,
+ .check = __au_glib_check,
+ .dispatch = __au_glib_dispatch,
+ .finalize = NULL
+};
+
+int _requset_init(struct amdmgr *amd)
+{
+ int fd;
+ int r;
+ GPollFD *gpollfd;
+ GSource *src;
+
+ fd = __create_server_sock(AUL_UTIL_PID);
+ src = g_source_new(&funcs, sizeof(GSource));
+
+ gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+ gpollfd->events = POLLIN;
+ gpollfd->fd = fd;
+
+ g_source_add_poll(src, gpollfd);
+ g_source_set_callback(src, (GSourceFunc) __request_handler,
+ (gpointer) gpollfd, NULL);
+ g_source_set_priority(src, G_PRIORITY_DEFAULT);
+
+ r = g_source_attach(src, NULL);
+ if (r == 0)
+ {
+ /* TODO: error handle*/
+ return -1;
+ }
+
+ _raf = amd->af;
+ _rcg = amd->cg;
+
+ r = rua_init();
+ r = rua_clear_history();
+
+ _D("rua_clear_history : %d", r);
+
+ return 0;
+}
+
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __AUL_AMD_REQUEST_H_
+#define __AUL_AMD_REQUEST_H_
+
+int _requset_init(struct amdmgr *amd);
+
+
+
+#endif
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdlib.h>
+#include <glib.h>
+#include <aul.h>
+#include <string.h>
+
+#include "amd_config.h"
+#include "amd_status.h"
+#include "amd_appinfo.h"
+#include "aul_util.h"
+#include "simple_util.h"
+#include "app_sock.h"
+#include "menu_db_util.h"
+
+GSList *app_status_info_list = NULL;
+
+struct appinfomgr *_saf = NULL;
+
+int _status_add_app_info_list(char *appid, char *app_path, int pid)
+{
+ GSList *iter = NULL;
+ app_status_info_t *info_t = NULL;
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+ if(pid == info_t->pid) {
+ return 0;
+ }
+ }
+
+ info_t = malloc(sizeof(app_status_info_t));
+ strncpy(info_t->appid, appid, MAX_PACKAGE_STR_SIZE-1);
+ strncpy(info_t->app_path, app_path, MAX_PACKAGE_APP_PATH_SIZE-1);
+ info_t->status = STATUS_LAUNCHING;
+ info_t->pid = pid;
+ app_status_info_list = g_slist_append(app_status_info_list, info_t);
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+
+ _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+ }
+
+ return 0;
+}
+
+int _status_update_app_info_list(int pid, int status)
+{
+ GSList *iter = NULL;
+ app_status_info_t *info_t = NULL;
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+ if(pid == info_t->pid) {
+ info_t->status = status;
+ break;
+ }
+ }
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+
+ _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+ }
+
+ return 0;
+}
+
+int _status_remove_app_info_list(int pid)
+{
+ GSList *iter = NULL;
+ app_status_info_t *info_t = NULL;
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+ if(pid == info_t->pid) {
+ app_status_info_list = g_slist_remove(app_status_info_list, info_t);
+ free(info_t);
+ break;
+ }
+ }
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+
+ _D("%s, %d, %d", info_t->appid, info_t->pid, info_t->status);
+ }
+
+ return 0;
+}
+
+int _status_app_is_running(char *appid)
+{
+ GSList *iter = NULL;
+ app_status_info_t *info_t = NULL;
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+ if( strncmp(appid, info_t->appid, MAX_PACKAGE_STR_SIZE) == 0 ) {
+ return info_t->pid;
+ }
+ }
+ return -1;
+}
+
+int _status_send_running_appinfo(int fd)
+{
+ GSList *iter = NULL;
+ app_status_info_t *info_t = NULL;
+ app_pkt_t *pkt = NULL;
+ int len;
+ char tmp_pid[MAX_PID_STR_BUFSZ];
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if(!pkt) {
+ _E("malloc fail");
+ return 0;
+ }
+
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ for (iter = app_status_info_list; iter != NULL; iter = g_slist_next(iter))
+ {
+ info_t = (app_status_info_t *)iter->data;
+ snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", info_t->pid);
+ strncat(pkt->data, tmp_pid, MAX_PID_STR_BUFSZ);
+ strncat(pkt->data, ":", 1);
+ strncat(pkt->data, info_t->appid, MAX_PACKAGE_STR_SIZE);
+ strncat(pkt->data, ":", 1);
+ strncat(pkt->data, info_t->app_path, MAX_PACKAGE_APP_PATH_SIZE);
+ strncat(pkt->data, ";", 1);
+ }
+
+ pkt->cmd = APP_RUNNING_INFO_RESULT;
+ pkt->len = strlen((char *)pkt->data) + 1;
+
+ if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
+ if (errno == EPIPE)
+ _E("send failed due to EPIPE.\n");
+ _E("send fail to client");
+ }
+
+ if(pkt)
+ free(pkt);
+
+ close(fd);
+
+ return 0;
+}
+
+int _status_app_is_running_v2(char *appid)
+{
+ char *apppath = NULL;
+ int ret = 0;
+ int i = 0;
+ struct appinfo *ai;
+
+ if(appid == NULL)
+ return -1;
+
+ ai = appinfo_find(_saf, appid);
+
+ if(ai == NULL)
+ return -1;
+
+ apppath = strdup(appinfo_get_value(ai, AIT_EXEC));
+
+ /*truncate apppath if it includes default bundles */
+ while (apppath[i] != 0) {
+ if (apppath[i] == ' ' || apppath[i] == '\t') {
+ apppath[i]='\0';
+ break;
+ }
+ i++;
+ }
+
+ ret = __proc_iter_cmdline(NULL, apppath);
+
+ free(apppath);
+
+ return ret;
+}
+
+static int __get_pkginfo(const char *dname, const char *cmdline, void *priv)
+{
+ app_info_from_db *menu_info;
+ char *r_info;
+
+ r_info = (char *)priv;
+
+ if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL)
+ goto out;
+ else {
+ strncat(r_info, dname, 8);
+ strncat(r_info, ":", 1);
+ strncat(r_info, _get_pkgname(menu_info), MAX_PACKAGE_STR_SIZE);
+ strncat(r_info, ":", 1);
+ strncat(r_info, _get_app_path(menu_info), MAX_PACKAGE_APP_PATH_SIZE);
+ strncat(r_info, ";", 1);
+ }
+
+ out:
+ if (menu_info != NULL)
+ _free_app_info_from_db(menu_info);
+ return 0;
+}
+
+int _status_send_running_appinfo_v2(int fd)
+{
+ app_pkt_t *pkt = NULL;
+ int len;
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if(!pkt) {
+ _E("malloc fail");
+ close(fd);
+ return 0;
+ }
+
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ __proc_iter_cmdline(__get_pkginfo, pkt->data);
+
+ pkt->cmd = APP_RUNNING_INFO_RESULT;
+ pkt->len = strlen((char *)pkt->data) + 1;
+
+ if ((len = send(fd, pkt, pkt->len + 8, 0)) != pkt->len + 8) {
+ if (errno == EPIPE)
+ _E("send failed due to EPIPE.\n");
+ _E("send fail to client");
+ }
+
+ if(pkt)
+ free(pkt);
+
+ close(fd);
+
+ return 0;
+}
+
+int _status_init(struct amdmgr* amd)
+{
+ _saf = amd->af;
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+
+int _status_add_app_info_list(char *appid, char *app_path, int pid);
+int _status_update_app_info_list(int pid, int status);
+int _status_remove_app_info_list(int pid);
+int _status_app_is_running(char *appid);
+int _status_send_running_appinfo(int fd);
+int _status_app_is_running_v2(char *appid);
+int _status_send_running_appinfo_v2(int fd);
+
+
+
+//TODO : remove
+
+typedef struct _item_pkt_t {
+ int pid;
+ char appid[512];
+} item_pkt_t;
+
+gboolean __add_item_running_list(gpointer user_data);
+
+
+
--- /dev/null
+<manifest>
+ <define>
+ <domain name="aul"/>
+ <provide>
+ <label name="aul::db"/>
+ </provide>
+ </define>
+ <assign>
+ <filesystem path="/usr/lib/libaul.so.0" label="_"/>
+ <filesystem path="/usr/lib/libaul.so.0.1.0" label="_"/>
+ <filesystem path="/etc/init.d/launchpad_run" label="_" exec_label="none"/>
+ <filesystem path="/etc/rc.d/rc3.d/S34launchpad_run" label="_" exec_label="none"/>
+ <filesystem path="/etc/rc.d/rc4.d/S80launchpad_run" label="_" exec_label="none"/>
+ </assign>
+ <request>
+ <domain name="aul"/>
+ </request>
+</manifest>
--- /dev/null
+# Package Information for pkg-config
+
+prefix=/usr
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@
+
+Name: libaul
+Description: new application utility library
+Version: @VERSION@
+Requires: sqlite3 bundle ail glib-2.0 xdgmime
+Libs: -L${libdir} -laul
+Cflags: -I${includedir}
--- /dev/null
+usage()
+{
+ echo "----------------------------------------------------------"
+ echo "aul_mime.sh package_name mimetype1 mimetype2 ... mimetypeN"
+ echo "----------------------------------------------------------"
+}
+
+if [ -z $1 ]
+then
+ echo "package name is NULL"
+ usage
+ exit
+fi
+
+if [ -z $2 ]
+then
+ echo "mimetype is NULL"
+ usage
+ exit
+fi
+
+pkg=$1
+shift
+while [ "$*" != "" ]
+do
+ sqlite3 /opt/dbspace/.mida.db "insert into mida(pkg_name,mime_type) values ('$pkg','$1')"
+ shift
+done
--- /dev/null
+usage()
+{
+ echo "--------------------------------------------------------------------------"
+ echo "aul_services.sh package_name service_name1 service_name2 ... service_nameN"
+ echo "--------------------------------------------------------------------------"
+}
+
+if [ -z $1 ]
+then
+ echo "package name is NULL"
+ usage
+ exit
+fi
+
+if [ -z $2 ]
+then
+ echo "service name is NULL"
+ usage
+ exit
+fi
+
+pkg=$1
+shift
+while [ "$*" != "" ]
+do
+ sqlite3 /opt/dbspace/.mida.db "insert into svc(pkg_name,svc_name) values ('$pkg','$1')"
+ shift
+done
--- /dev/null
+usage()
+{
+ echo "---------------------------------"
+ echo "aul_service_test.sh service_name"
+ echo "---------------------------------"
+}
+
+if [ -z $1 ]
+then
+ echo "service name is NULL"
+ usage
+ exit
+fi
+
+sqlite3 /opt/dbspace/.mida.db "insert into system_svc(svc_name) values ('$1')"
--- /dev/null
+mkdir -p $OUTDIR
+pushd $OUTDIR
+
+mkdir -p contact/cmds
+mkdir -p contact/apps
+
+echo 0 > contact/cmds/create
+echo 0 > contact/cmds/view
+echo 0 > contact/cmds/edit
+echo 1 > contact/cmds/search
+echo "" > contact/apps/org.tizen.contacts
+
+mkdir -p calendar/cmds
+mkdir -p calendar/apps
+
+echo 0 > calendar/cmds/create
+echo 0 > calendar/cmds/view
+echo "" > calendar/apps/org.tizen.efl-calendar
+
+mkdir -p memo/cmds
+mkdir -p memo/apps
+
+echo 0 > memo/cmds/create
+echo 0 > memo/cmds/view
+echo "" > memo/apps/org.tizen.memo
+
+mkdir -p email/cmds
+mkdir -p email/apps
+
+echo 0 > email/cmds/create
+echo 0 > email/cmds/view
+echo "" > email/apps/org.tizen.email
+
+mkdir -p message/cmds
+mkdir -p message/apps
+
+echo 0 > message/cmds/create
+echo 0 > message/cmds/view
+echo "" > message/apps/org.tizen.message
+
+mkdir -p camera/cmds
+mkdir -p camera/apps
+
+echo 1 > camera/cmds/take_picture
+echo 1 > camera/cmds/rec_video
+echo 1 > camera/cmds/read_barcode
+echo "" > camera/apps/org.tizen.camera-app
+
+mkdir -p voice_record/cmds
+mkdir -p voice_record/apps
+
+echo 1 > voice_record/cmds/rec_voice
+echo "" > voice_record/apps/org.tizen.voicerecorder
+
+mkdir -p file_browser/cmds
+mkdir -p file_browser/apps
+
+echo 0 > file_browser/cmds/browse
+echo "" > file_browser/apps/org.tizen.myfile
+
+mkdir -p map/cmds
+mkdir -p map/apps
+
+echo 0 > map/cmds/show_place
+echo 0 > map/cmds/route_path
+
+mkdir -p alarm/cmds
+mkdir -p alarm/apps
+
+echo 0 > alarm/cmds/create
+echo "" > alarm/apps/org.tizen.alarm
+
+mkdir -p search/cmds
+mkdir -p search/apps
+
+echo 1 > search/cmds/search
+echo "" > search/apps/org.tizen.smartsearch
+
+mkdir -p voice_call/cmds
+mkdir -p voice_call/apps
+
+echo 0 > voice_call/cmds/mtcall
+echo 0 > voice_call/cmds/mocall
+echo "" > voice_call/apps/org.tizen.voice-call-ui
+
+mkdir -p video_call/cmds
+mkdir -p video_call/apps
+
+echo 0 > video_call/cmds/mtcall
+echo 0 > video_call/cmds/mocall
+echo "" > video_call/apps/org.tizen.vtmain
+
+popd
+
+sync
+
--- /dev/null
+PRAGMA journal_mode = PERSIST;
+
+CREATE TABLE IF NOT EXISTS mida (
+ id INTEGER PRIMARY KEY,
+ pkg_name TEXT,
+ mime_type TEXT UNIQUE NOT NULL
+);
+
+CREATE TABLE IF NOT EXISTS svc (
+ id INTEGER PRIMARY KEY,
+ pkg_name TEXT,
+ svc_name TEXT UNIQUE NOT NULL
+);
+
+DROP TABLE IF EXISTS system_svc;
+
+CREATE TABLE IF NOT EXISTS system_svc (
+ id INTEGER PRIMARY KEY,
+ svc_name TEXT UNIQUE NOT NULL
+);
+
+
+INSERT INTO system_svc(svc_name) VALUES ("create_alarm");
+INSERT INTO system_svc(svc_name) VALUES ("open_calendar");
+INSERT INTO system_svc(svc_name) VALUES ("create_event");
+INSERT INTO system_svc(svc_name) VALUES ("view_event");
+INSERT INTO system_svc(svc_name) VALUES ("take_picture");
+INSERT INTO system_svc(svc_name) VALUES ("record_video");
+INSERT INTO system_svc(svc_name) VALUES ("read_barcode");
+INSERT INTO system_svc(svc_name) VALUES ("search_contact");
+INSERT INTO system_svc(svc_name) VALUES ("create_email");
+INSERT INTO system_svc(svc_name) VALUES ("view_email");
+INSERT INTO system_svc(svc_name) VALUES ("browse_file");
+INSERT INTO system_svc(svc_name) VALUES ("create_memo");
+INSERT INTO system_svc(svc_name) VALUES ("view_memo");
+INSERT INTO system_svc(svc_name) VALUES ("create_message");
+INSERT INTO system_svc(svc_name) VALUES ("view_message");
+INSERT INTO system_svc(svc_name) VALUES ("search");
+INSERT INTO system_svc(svc_name) VALUES ("make_videocall");
+INSERT INTO system_svc(svc_name) VALUES ("make_voicecall");
+INSERT INTO system_svc(svc_name) VALUES ("record_voice");
+INSERT INTO system_svc(svc_name) VALUES ("play_music");
+INSERT INTO system_svc(svc_name) VALUES ("browse_web");
+INSERT INTO system_svc(svc_name) VALUES ("update_facebook");
+INSERT INTO system_svc(svc_name) VALUES ("update_twitter");
+INSERT INTO system_svc(svc_name) VALUES ("open_ebook");
+
--- /dev/null
+^( )*callto:(//+)?(\+)?[0-9]+$
+Call Client
--- /dev/null
+(^( )*contact_shortcut:)([0-9]+:)([+]|[#]+)?([0-9]+)
+Contact Shortcut Internal
--- /dev/null
+(^( )*mailto:[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)|(^( )*[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)
+Email Client
--- /dev/null
+^( )*file:///?[a-zA-Z0-9._-]+
+Browser or FileManager client
--- /dev/null
+(^( )*http(s)?://)|(^( )*www.)
+Browser Client
--- /dev/null
+^( )*im:[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]*
--- /dev/null
+^( )*[NSWE]( )*[0-9]+(.[0-9]+)*([ ,;])*[NSWE]( )*[0-9]+(.[0-9]+)*
--- /dev/null
+^( )*mmsto:(\+)?[0-9-]+\?cc=(([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)|((\+)?[0-9-]+))?&subject=.+$
--- /dev/null
+^(\+)?[0-9/.-]*(\\([0-9]+\\))?[0-9/.-]{7,}
--- /dev/null
+^( )*sms:(\+)?[0-9-]+$
--- /dev/null
+^( )*tel:(//+)?(\+)?[0-9-]+$
--- /dev/null
+system service directory
--- /dev/null
+aul-1 (0.0.179) unstable; urgency=low
+
+ * changed to use the application ID
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.179
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 05 Jun 2012 20:01:49 +0900
+
+aul-1 (0.0.178) unstable; urgency=low
+
+ * Added exception handling in __app_send_cmd_with_result()
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.178
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 15 May 2012 17:03:32 +0900
+
+aul-1 (0.0.177) unstable; urgency=low
+
+ * Removed elementary dependency
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.177
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 02 May 2012 11:52:12 +0900
+
+aul-1 (0.0.176) unstable; urgency=low
+
+ * Added key event module
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.176
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 30 Apr 2012 13:52:09 +0900
+
+aul-1 (0.0.175) unstable; urgency=low
+
+ * Extended timeout
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.175
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 24 Apr 2012 17:40:20 +0900
+
+aul-1 (0.0.174) unstable; urgency=low
+
+ * Fixed hibernation bug
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.174
+
+ -- jaeho81.lee <jaeho81.lee@samsung.com> Thu, 19 Apr 2012 15:18:17 +0900
+
+aul-1 (0.0.173) unstable; urgency=low
+
+ * Fixed __launchpad_sig_child bug
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.173
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 04 Apr 2012 13:36:13 +0900
+
+aul-1 (0.0.172) unstable; urgency=low
+
+ * Removed waiting profile_ready
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.172
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 02 Apr 2012 13:29:52 +0900
+
+aul-1 (0.0.171) unstable; urgency=low
+
+ * Fixed __app_dbus_signal_handler_fini bug
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.171
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 30 Mar 2012 19:03:47 +0900
+
+aul-1 (0.0.170) unstable; urgency=low
+
+ * Add new APIs
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.170
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 29 Mar 2012 10:20:52 +0900
+
+aul-1 (0.0.169) unstable; urgency=low
+
+ * Fixed compile warnings
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.169
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 20 Mar 2012 14:36:05 +0900
+
+aul-1 (0.0.168) unstable; urgency=low
+
+ * Fix buffer overflow bug
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.168
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 20 Mar 2012 00:20:29 +0900
+
+aul-1 (0.0.167) unstable; urgency=low
+
+ * Fix buffer overflow bug
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.167
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 19 Mar 2012 21:08:42 +0900
+
+aul-1 (0.0.166) unstable; urgency=low
+
+ * Fix rua add history bug
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.166
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 16 Mar 2012 13:48:08 +0900
+
+aul-1 (0.0.165) unstable; urgency=low
+
+ * changed spec file
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.165
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 15 Mar 2012 22:47:29 +0900
+
+aul-1 (0.0.164) unstable; urgency=low
+
+ * rua add history
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.164
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 15 Mar 2012 18:17:38 +0900
+
+aul-1 (0.0.163) unstable; urgency=low
+
+ * Add aul_finalize()
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.163
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 28 Feb 2012 16:55:15 +0900
+
+aul-1 (0.0.162) unstable; urgency=low
+
+ * Add rua
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.162
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 15 Feb 2012 19:19:54 +0900
+
+aul-1 (0.0.161) unstable; urgency=low
+
+ * Add pre_exec before execution
+ * Git: slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.161
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 02 Feb 2012 14:43:05 +0900
+
+aul-1 (0.0.160) unstable; urgency=low
+
+ * Fix ELM SCALE bug
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.160
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 31 Jan 2012 18:27:08 +0900
+
+aul-1 (0.0.159) unstable; urgency=low
+
+ * Support SDK
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.159
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 30 Jan 2012 20:02:26 +0900
+
+aul-1 (0.0.158) unstable; urgency=low
+
+ * Remove setenv for scale
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.158
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 18 Jan 2012 17:15:11 +0900
+
+aul-1 (0.0.157) unstable; urgency=low
+
+ * Fix aul_open_app bug
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.157
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 11 Jan 2012 15:40:27 +0900
+
+aul-1 (0.0.156) unstable; urgency=low
+
+ * Modify aul.spec
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.156
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 22 Dec 2011 10:10:34 +0900
+
+aul-1 (0.0.155) unstable; urgency=low
+
+ * Remove systemd dependency
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.155
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 21 Dec 2011 11:01:54 +0900
+
+aul-1 (0.0.154) unstable; urgency=low
+
+ * Fix code for CQ H0100137729
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.154
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 09 Dec 2011 11:40:18 +0900
+
+aul-1 (0.0.153) unstable; urgency=low
+
+ * Ignore permission error
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.153
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 05 Dec 2011 15:39:47 +0900
+
+aul-1 (0.0.152) unstable; urgency=low
+
+ * Fix code for CQ H0100135781
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.152
+
+ -- Sewook Park <sewook7.park@samsung.com> Thu, 01 Dec 2011 19:18:23 +0900
+
+aul-1 (0.0.151) unstable; urgency=low
+
+ * Modify reply handling of aul_send_result
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.151
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 30 Nov 2011 18:32:50 +0900
+
+aul-1 (0.0.150) unstable; urgency=low
+
+ * Support SMACK
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.150
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 29 Nov 2011 14:59:30 +0900
+
+aul-1 (0.0.149) unstable; urgency=low
+
+ * Support SDK
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.149
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 24 Nov 2011 10:37:42 +0900
+
+aul-1 (0.0.148) unstable; urgency=low
+
+ * Modify XInternAtom function arg
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.148
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 08 Nov 2011 12:59:46 +0900
+
+aul-1 (0.0.147) unstable; urgency=low
+
+ * Changed Boilerplate as per the guideline
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.147
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 07 Nov 2011 18:03:15 +0900
+
+aul-1 (0.0.146) unstable; urgency=low
+
+ * Add logs
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.146
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 04 Nov 2011 17:41:14 +0900
+
+aul-1 (0.0.145) unstable; urgency=low
+
+ * Remove socket file before launching
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.145
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 03 Nov 2011 14:54:48 +0900
+
+aul-1 (0.0.144) unstable; urgency=low
+
+ * Fix svace defects
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.144
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 27 Oct 2011 10:13:32 +0900
+
+aul-1 (0.0.143) unstable; urgency=low
+
+ * Modify aul_send_result
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.143
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 20 Oct 2011 12:26:28 +0900
+
+aul-1 (0.0.142) unstable; urgency=low
+
+ * add ac_daemon
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.142
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 17 Oct 2011 19:16:11 +0900
+
+aul-1 (0.0.141) unstable; urgency=low
+
+ * Modify oom adj value
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.141
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Thu, 06 Oct 2011 17:04:05 +0900
+
+aul-1 (0.0.140) unstable; urgency=low
+
+ * Use strncmp when comparing command line with Exec
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.140
+
+ -- Sewook Park <sewook7.park@samsung.com> Fri, 30 Sep 2011 11:09:25 +0900
+
+aul-1 (0.0.139) unstable; urgency=low
+
+ * AIL DB close
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.139
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 26 Sep 2011 19:25:00 +0900
+
+aul-1 (0.0.138) unstable; urgency=low
+
+ * Code cleanup
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.138
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 21 Sep 2011 11:36:58 +0900
+
+aul-1 (0.0.137) unstable; urgency=low
+
+ * Fix prevent defects
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.137
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Sat, 20 Aug 2011 18:05:34 +0900
+
+aul-1 (0.0.136) unstable; urgency=low
+
+ * Fix TC error
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.136
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 19 Aug 2011 13:32:23 +0900
+
+aul-1 (0.0.135) unstable; urgency=low
+
+ * Remove package dependency
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.135
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 17 Aug 2011 10:06:01 +0900
+
+aul-1 (0.0.134) unstable; urgency=low
+
+ * Modify TC Makefile
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.134
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 16 Aug 2011 14:49:35 +0900
+
+aul-1 (0.0.133) unstable; urgency=low
+
+ * Fix prevent defects
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.133
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Sat, 13 Aug 2011 18:31:09 +0900
+
+aul-1 (0.0.132) unstable; urgency=low
+
+ * Fix aul_app_get_running_app_info bug
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.132
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 10 Aug 2011 14:31:06 +0900
+
+aul-1 (0.0.131) unstable; urgency=low
+
+ * Apply app-svc
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.131
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 09 Aug 2011 11:45:18 +0900
+
+aul-1 (0.0.130) unstable; urgency=low
+
+ * ail API change
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.130
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 08 Aug 2011 16:27:27 +0900
+
+aul-1 (0.0.129) unstable; urgency=low
+
+ * Fix aul_app_is_running bug
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.129
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 03 Aug 2011 19:39:42 +0900
+
+aul-1 (0.0.128) unstable; urgency=low
+
+ * Change preload list
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.128
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 03 Aug 2011 17:25:36 +0900
+
+aul-1 (0.0.127) unstable; urgency=low
+
+ * Code cleanup
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.127
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Mon, 01 Aug 2011 19:30:19 +0900
+
+aul-1 (0.0.126) unstable; urgency=low
+
+ * Local launch
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.126
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 22 Jul 2011 13:08:54 +0900
+
+aul-1 (0.0.125) unstable; urgency=low
+
+ * Code cleanup
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.125
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Wed, 13 Jul 2011 16:18:49 +0900
+
+aul-1 (0.0.124) unstable; urgency=low
+
+ * Add cmdline check routine & Fix prevent defects
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.124
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 01 Jul 2011 11:29:20 +0900
+
+aul-1 (0.0.123) unstable; urgency=low
+
+ * Fix __connect_nonb
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.123
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 21 Jun 2011 14:44:17 +0900
+
+aul-1 (0.0.122) unstable; urgency=low
+
+ * Comment out command line check routine
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.122
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Fri, 17 Jun 2011 17:36:02 +0900
+
+aul-1 (0.0.121) unstable; urgency=low
+
+ * Fix launch_app
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.121
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Sat, 11 Jun 2011 16:59:21 +0900
+
+aul-1 (0.0.120) unstable; urgency=low
+
+ * Fix create_argc_argv()
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.120
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 08 Jun 2011 15:29:02 +0900
+
+aul-1 (0.0.119) unstable; urgency=low
+
+ * Fix build error
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.119
+
+ -- Sewook Park <sewook7.park@samsung.com> Wed, 08 Jun 2011 11:10:22 +0900
+
+aul-1 (0.0.118) unstable; urgency=low
+
+ * Fix argc in launchpad
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.118
+
+ -- Sewook Park <sewook7.park@samsung.com> Tue, 07 Jun 2011 23:47:20 +0900
+
+aul-1 (0.0.117) unstable; urgency=low
+
+ * Fix API aul_get_defapp_from_mime
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.117
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 31 May 2011 13:46:48 +0900
+
+aul-1 (0.0.116) unstable; urgency=low
+
+ * Fix pwlock issue
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.116
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com> Tue, 24 May 2011 17:52:38 +0900
+
+aul-1 (0.0.115) unstable; urgency=low
+
+ * AIL change
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.115
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Wed, 18 May 2011 10:03:58 +0900
+
+aul-1 (0.0.114) unstable; urgency=low
+
+ * Fix memory issue in case when several apps share the same app path
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.114
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 12 May 2011 08:59:44 +0900
+
+aul-1 (0.0.113) unstable; urgency=low
+
+ * Remove temp code for new pkgname policy
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.113
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 21 Apr 2011 12:24:50 +0900
+
+aul-1 (0.0.112) unstable; urgency=low
+
+ * Adding new API aul_open_app, which will replace aul_resume_app
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.112
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Mon, 18 Apr 2011 10:57:21 +0900
+
+aul-1 (0.0.111) unstable; urgency=low
+
+ * Temporary change during reflecting the new pkg name policy
+ * Update encoded package names
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.111
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Mon, 11 Apr 2011 21:37:05 +0900
+
+aul-1 (0.0.110) unstable; urgency=low
+
+ * Prevent BS due to EPIPE
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.110
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Wed, 06 Apr 2011 14:16:32 +0900
+
+aul-1 (0.0.109) unstable; urgency=low
+
+ * Setting process name with app name for top
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.109
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 17 Mar 2011 14:15:41 +0900
+
+aul-1 (0.0.108) unstable; urgency=low
+
+ * Adding new AUL services
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.108
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Wed, 16 Mar 2011 11:56:30 +0900
+
+aul-1 (0.0.107) unstable; urgency=low
+
+ * Applying Active Flushing
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.107
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 10 Mar 2011 16:07:38 +0900
+
+aul-1 (0.0.106) unstable; urgency=low
+
+ * Show err msg for cmdline not changed
+ * Fix recv_raw bug
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.106
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Mon, 07 Mar 2011 17:14:11 +0900
+
+aul-1 (0.0.105) unstable; urgency=low
+
+ * Fix connect lock-up
+ * Modifly launch-app for SDK
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.105
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 24 Feb 2011 18:08:33 +0900
+
+aul-1 (0.0.104) unstable; urgency=low
+
+ * Add launch_app command for SDK
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.104
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Fri, 18 Feb 2011 17:54:52 +0900
+
+aul-1 (0.0.103) unstable; urgency=low
+
+ * Fix prevent defects
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.103
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Wed, 16 Feb 2011 15:13:28 +0900
+
+aul-1 (0.0.102) unstable; urgency=low
+
+ * Modifly get_defapp_for_service
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.102
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Tue, 15 Feb 2011 19:00:50 +0900
+
+aul-1 (0.0.101) unstable; urgency=low
+
+ * Modify URI for MMS
+ * Fix the PIPE issue
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.101
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Tue, 15 Feb 2011 08:47:40 +0900
+
+aul-1 (0.0.100) unstable; urgency=low
+
+ * Modify URI for sms, mms
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.100
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Fri, 11 Feb 2011 20:06:38 +0900
+
+aul-1 (0.0.99) unstable; urgency=low
+
+ * Modify URI regex for callto, phonenum, tel to recognize +
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.99
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Wed, 09 Feb 2011 20:01:50 +0900
+
+aul-1 (0.0.98) unstable; urgency=low
+
+ * Modify testing app for TC
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.98
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Fri, 28 Jan 2011 14:52:33 +0900
+
+aul-1 (0.0.97) unstable; urgency=low
+
+ * Modify AUL Service APIs
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.97
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Wed, 26 Jan 2011 08:57:58 +0900
+
+aul-1 (0.0.96) unstable; urgency=low
+
+ * Enable AUL Log messages
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.96
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Mon, 24 Jan 2011 12:08:48 +0900
+
+aul-1 (0.0.95) unstable; urgency=low
+
+ * Rollback the change of Service API
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.95
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 20 Jan 2011 14:05:54 +0900
+
+aul-1 (0.0.94) unstable; urgency=low
+
+ * Update AUL Service APIs
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.94
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 20 Jan 2011 11:33:31 +0900
+
+aul-1 (0.0.93) unstable; urgency=low
+
+ * Modify TC files
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.93
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 13 Jan 2011 14:05:08 +0900
+
+aul-1 (0.0.92) unstable; urgency=low
+
+ * Modified MIME API internal function to handle null string input
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.92
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 06 Jan 2011 13:03:00 +0900
+
+aul-1 (0.0.91) unstable; urgency=low
+
+ * Disabled fake image effect
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.91
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Wed, 05 Jan 2011 20:17:19 +0900
+
+aul-1 (0.0.90) unstable; urgency=low
+
+ * Re-adjusted OOM value to -14 from 0 as requested
+ * Added a new bundle key for unaliased mime type
+ * Temporary modification to hide fake image (final update will be added later)
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.90
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Mon, 27 Dec 2010 14:24:22 +0900
+
+aul-1 (0.0.89) unstable; urgency=low
+
+ * Modify TC to avoid the timing issue among test cases
+ * Modify mime-related API to correctly set/get mime db info
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.89
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 23 Dec 2010 17:42:38 +0900
+
+aul-1 (0.0.88) unstable; urgency=low
+
+ * Modify menu db function to correctly retrieve the running apps info
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.88
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Mon, 20 Dec 2010 16:15:14 +0900
+
+aul-1 (0.0.87) unstable; urgency=low
+
+ * Use screen-engine's DB access functions and cleaned up the internal DB-related functions
+ * Run fake launch effect in AUL instead of menu screen
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.87
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Fri, 17 Dec 2010 11:55:30 +0900
+
+aul-1 (0.0.86) unstable; urgency=low
+
+ * Using desktop_get_item instead of RECORD_GET to reduce desktop DB handling time
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.86
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Thu, 16 Dec 2010 03:03:48 +0900
+
+aul-1 (0.0.85) unstable; urgency=low
+
+ * Modified libaul-1-executable.postinst and libaul-1.postinst
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.85
+
+ -- Yoonkyong Lee <yk6629.lee@samsung.com> Wed, 15 Dec 2010 09:49:31 +0900
+
+aul-1 (0.0.84) unstable; urgency=low
+
+ * Add /usr/lib/ecore/immodules/isf-imf-module.so to preload_list.txt
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.84
+
+ -- Youmin Ha <youmin.ha@samsung.com> Tue, 14 Dec 2010 20:03:26 +0900
+
+aul-1 (0.0.83) unstable; urgency=low
+
+ * Add time check log
+ * Git: 165.213.180.234:/slp/pkgs/a/aul-1
+ * Tag: aul-1_0.0.83
+
+ -- Youmin Ha <youmin.ha@samsung.com> Sat, 11 Dec 2010 16:45:33 +0900
+
+aul-1 (0.0.82) unstable; urgency=low
+
+ * support deb.org.tizen.* package names
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.82
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 24 Nov 2010 09:59:24 +0900
+
+aul-1 (0.0.81) unstable; urgency=low
+
+ * add launchpad launcher for rc4, revert 1777 permission
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.81
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 17 Nov 2010 17:33:38 +0900
+
+aul-1 (0.0.80-1) unstable; urgency=low
+
+ * reupload
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.80-1
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 17 Nov 2010 10:56:30 +0900
+
+aul-1 (0.0.80) unstable; urgency=low
+
+ * Apply security patch by Baik, Change permission of miregex/ dir to 1777
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.80
+
+ -- Youmin Ha <youmin.ha@samsung.com> Wed, 17 Nov 2010 10:41:34 +0900
+
+aul-1 (0.0.79) unstable; urgency=low
+
+ * include sqlite3 in depend pkgs
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.79
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 11 Nov 2010 11:41:54 +0900
+
+aul-1 (0.0.78) unstable; urgency=low
+
+ * pkg re-upload
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.78
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 11 Nov 2010 10:19:19 +0900
+
+aul-1 (0.0.77) unstable; urgency=low
+
+ * db installation : install ==> postinstall
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.77
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 11 Nov 2010 08:59:33 +0900
+
+aul-1 (0.0.76) unstable; urgency=low
+
+ * doxygen work
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.76
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 03 Nov 2010 19:10:18 +0900
+
+aul-1 (0.0.75) unstable; urgency=low
+
+ * modify aul_get_mime_extenstion
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.75
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 29 Oct 2010 15:19:50 +0900
+
+aul-1 (0.0.74) unstable; urgency=low
+
+ * modify scale direction (fix with menu_db)
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.74
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 27 Oct 2010 14:57:57 +0900
+
+aul-1 (0.0.73) unstable; urgency=low
+
+ * modify scale direction
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.73
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 27 Oct 2010 14:05:20 +0900
+
+aul-1 (0.0.72) unstable; urgency=low
+
+ * support miregex description and updating miregex and add 2 APIs
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.72
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 27 Oct 2010 11:30:17 +0900
+
+aul-1 (0.0.71) unstable; urgency=low
+
+ * support alias mimetype
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.71
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 25 Oct 2010 17:53:48 +0900
+
+aul-1 (0.0.70) unstable; urgency=low
+
+ * lazy preinit util launching first pkg
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.70
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 25 Oct 2010 10:13:59 +0900
+
+aul-1 (0.0.69) unstable; urgency=low
+
+ * add contact_shortcut.uri
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.69
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 22 Oct 2010 13:17:15 +0900
+
+aul-1 (0.0.68) unstable; urgency=low
+
+ * change mimetype max length & auto-set default application when 1 application
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.68
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 21 Oct 2010 17:01:31 +0900
+
+aul-1 (0.0.67) unstable; urgency=low
+
+ * change max cmdline when preloading
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.67
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 21 Oct 2010 10:47:11 +0900
+
+aul-1 (0.0.66) unstable; urgency=low
+
+ * add libprivileg-control
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.66
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 21 Oct 2010 08:49:50 +0900
+
+aul-1 (0.0.65) unstable; urgency=low
+
+ * build error fix
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.65
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 20 Oct 2010 17:00:20 +0900
+
+aul-1 (0.0.64) unstable; urgency=low
+
+ * build by upgrading xdgmime version
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.64
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 20 Oct 2010 16:39:36 +0900
+
+aul-1 (0.0.63) unstable; urgency=low
+
+ * Modify Race Condition Problem in single instance
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.63
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 19 Oct 2010 14:06:27 +0900
+
+aul-1 (0.0.62) unstable; urgency=low
+
+ * modify PG according to SPRC/SERI
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.62
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 18 Oct 2010 11:29:21 +0900
+
+aul-1 (0.0.61) unstable; urgency=low
+
+ * aul_open_file_with_mimetype bug fix
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.61
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 15 Oct 2010 20:45:11 +0900
+
+aul-1 (0.0.60) unstable; urgency=low
+
+ * remove aul_launch_with_result to guiding by mike
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.60
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 15 Oct 2010 18:35:18 +0900
+
+aul-1 (0.0.59) unstable; urgency=low
+
+ * modify service API according to guiding by mike. (Lacking const, Header
+ file Directory)
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.59
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 15 Oct 2010 12:03:12 +0900
+
+aul-1 (0.0.58) unstable; urgency=low
+
+ * pid-pgid mapping check at single instance
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.58
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 14 Oct 2010 17:06:39 +0900
+
+aul-1 (0.0.57) unstable; urgency=low
+
+ * update by desktop-library structure change
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.57
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 13 Oct 2010 18:50:01 +0900
+
+aul-1 (0.0.56) unstable; urgency=low
+
+ * add X error handling
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.56
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 12 Oct 2010 21:48:05 +0900
+
+aul-1 (0.0.55) unstable; urgency=low
+
+ * give EFL signal handler to child
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.55
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 12 Oct 2010 10:20:57 +0900
+
+aul-1 (0.0.54) unstable; urgency=low
+
+ * remove ELM_THEHE, kill same process groupid when child died
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.54
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 07 Oct 2010 20:50:55 +0900
+
+aul-1 (0.0.53) unstable; urgency=low
+
+ * add timeout feature
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.53
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 06 Oct 2010 21:04:35 +0900
+
+aul-1 (0.0.52) unstable; urgency=low
+
+ * usr -> opt
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.52
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 06 Oct 2010 17:25:25 +0900
+
+aul-1 (0.0.51) unstable; urgency=low
+
+ * libaul-1-executable debian bug fix
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.51
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 04 Oct 2010 14:44:36 +0900
+
+aul-1 (0.0.50) unstable; urgency=low
+
+ * divide libaul and libaul-executable (due to dependency X/Ecore)
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.50
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 04 Oct 2010 10:36:58 +0900
+
+aul-1 (0.0.49) unstable; urgency=low
+
+ * add service api
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.49
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 27 Sep 2010 19:32:14 +0900
+
+aul-1 (0.0.48) unstable; urgency=low
+
+ * update due to screen-engine ABI change
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.48
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 17 Sep 2010 16:58:05 +0900
+
+aul-1 (0.0.47) unstable; urgency=low
+
+ * add multiple instance field, add prctl(PR_SET_DUMPABLE)
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.47
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 15 Sep 2010 15:32:28 +0900
+
+aul-1 (0.0.46) unstable; urgency=low
+
+ * EFL upgrade
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.46
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 13 Sep 2010 09:24:35 +0900
+
+aul-1 (0.0.45) unstable; urgency=low
+
+ * TC work done
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.45
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 10 Sep 2010 15:43:17 +0900
+
+aul-1 (0.0.44) unstable; urgency=low
+
+ * fix build error
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.44
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 09 Sep 2010 12:01:26 +0900
+
+aul-1 (0.0.43) unstable; urgency=low
+
+ * release MIME API
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.43
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 09 Sep 2010 11:23:25 +0900
+
+aul-1 (0.0.42) unstable; urgency=low
+
+ * temprory release - by yoomin.ha
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.42
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 09 Sep 2010 11:23:25 +0900
+
+aul-1 (0.0.41) unstable; urgency=low
+
+ * disable SUPPORT_SYSASSERT
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.41
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 02 Sep 2010 18:38:45 +0900
+
+aul-1 (0.0.40) unstable; urgency=low
+
+ * transfer some signal handlers to child for sys-assert
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.40
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 02 Sep 2010 14:17:26 +0900
+
+aul-1 (0.0.39) unstable; urgency=low
+
+ * add aul_kill_pid API for task_manager, modify dbus shared connection ==> dbus private connection
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.39
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 02 Sep 2010 11:51:22 +0900
+
+aul-1 (0.0.38) unstable; urgency=low
+
+ * bug fix - size problem, dbus realloc lock problem
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.38
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 30 Aug 2010 23:26:11 +0900
+
+aul-1 (0.0.37) unstable; urgency=low
+
+ * re-upload
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.37
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 27 Aug 2010 14:22:03 +0900
+
+aul-1 (0.0.36) unstable; urgency=low
+
+ * enable preload & pre-initialize
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.36
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 27 Aug 2010 14:12:29 +0900
+
+aul-1 (0.0.35) unstable; urgency=low
+
+ * remove DISPLAY enviroment (X should be set)
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.35
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 25 Aug 2010 16:48:16 +0900
+
+aul-1 (0.0.34) unstable; urgency=low
+
+ * sprintf -> snprintf
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.34
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 25 Aug 2010 11:35:48 +0900
+
+aul-1 (0.0.33) unstable; urgency=low
+
+ * add doxygen work , prepare to remove aul_launch_with_result
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.33
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 23 Aug 2010 23:08:48 +0900
+
+aul-1 (0.0.32) unstable; urgency=low
+
+ * add APP_START_TIME environment
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.32
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 18 Aug 2010 16:05:03 +0900
+
+aul-1 (0.0.31) unstable; urgency=low
+
+ * bug fix - readproc fix close
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.31
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 18 Aug 2010 12:41:28 +0900
+
+aul-1 (0.0.30) unstable; urgency=low
+
+ * add dbus auto-activation test
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.30
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 18 Aug 2010 09:57:32 +0900
+
+aul-1 (0.0.29) unstable; urgency=low
+
+ * add exception case - shell script , no app-core ...
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.29
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Mon, 16 Aug 2010 21:57:14 +0900
+
+aul-1 (0.0.28) unstable; urgency=low
+
+ * mime content done
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.28
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 12 Aug 2010 20:59:21 +0900
+
+aul-1 (0.0.27) unstable; urgency=low
+
+ * delete journal db
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.27
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 11 Aug 2010 12:58:16 +0900
+
+aul-1 (0.0.26) unstable; urgency=low
+
+ * add app dead signal using dbus
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.26
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 11 Aug 2010 11:26:47 +0900
+
+aul-1 (0.0.25) unstable; urgency=low
+
+ * add sticky bit - /tmp/alaunch
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.25
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 10 Aug 2010 20:23:13 +0900
+
+aul-1 (0.0.24) unstable; urgency=low
+
+ * rollback security
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.24
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 10 Aug 2010 20:05:16 +0900
+
+aul-1 (0.0.23) unstable; urgency=low
+
+ * more security enhanced
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.23
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 10 Aug 2010 18:54:01 +0900
+
+aul-1 (0.0.22) unstable; urgency=low
+
+ * build fix
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.22
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 10 Aug 2010 14:07:58 +0900
+
+aul-1 (0.0.21) unstable; urgency=low
+
+ * bug fix related by DAC - /tmp/alaunch permission
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.21
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 10 Aug 2010 14:05:23 +0900
+
+aul-1 (0.0.20) unstable; urgency=low
+
+ * build fix
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.20
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 10 Aug 2010 09:14:28 +0900
+
+aul-1 (0.0.19) unstable; urgency=low
+
+ * support mime api
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.19
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 10 Aug 2010 08:26:03 +0900
+
+aul-1 (0.0.18) unstable; urgency=low
+
+ * aul_test minor change
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.18
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 06 Aug 2010 17:11:45 +0900
+
+aul-1 (0.0.17) unstable; urgency=low
+
+ * clear internal key
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.17
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 06 Aug 2010 12:39:09 +0900
+
+aul-1 (0.0.16) unstable; urgency=low
+
+ * modification with mike'review - modify return value, argv->bundle
+ conversion
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.16
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 05 Aug 2010 14:35:20 +0900
+
+aul-1 (0.0.15) unstable; urgency=low
+
+ * modification of API(remove dead_handler, remove aul_get_app_info,
+ aul_free_app_info, add const to argument)
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.15
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 04 Aug 2010 14:41:49 +0900
+
+aul-1 (0.0.14) unstable; urgency=low
+
+ * add dlog
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.14
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 30 Jul 2010 17:41:56 +0900
+
+aul-1 (0.0.13) unstable; urgency=low
+
+ * add theme
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.13
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 30 Jul 2010 16:37:33 +0900
+
+aul-1 (0.0.12) unstable; urgency=low
+
+ * reupload2
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.12
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 30 Jul 2010 14:07:31 +0900
+
+aul-1 (0.0.11) unstable; urgency=low
+
+ * reupload
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.11
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 30 Jul 2010 13:50:44 +0900
+
+aul-1 (0.0.10) unstable; urgency=low
+
+ * upgrade aul_test program
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.9
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Fri, 30 Jul 2010 13:44:31 +0900
+
+aul-1 (0.0.9) unstable; urgency=low
+
+ * glib integration API by default
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.9
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 29 Jul 2010 22:06:35 +0900
+
+aul-1 (0.0.8) unstable; urgency=low
+
+ * add resume, terminate, ... add argv0, check more security
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.8
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 29 Jul 2010 19:55:24 +0900
+
+aul-1 (0.0.6) unstable; urgency=low
+
+ * add resume, terminate, ... add argv0, check more security
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.7
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Thu, 29 Jul 2010 19:44:15 +0900
+
+aul-1 (0.0.5) unstable; urgency=low
+
+ * re-upload due to ecore package dependency
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.5
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Wed, 28 Jul 2010 09:24:21 +0900
+
+aul-1 (0.0.4) unstable; urgency=low
+
+ * re-upload due to tag verfication
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.4
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 27 Jul 2010 21:40:58 +0900
+
+aul-1 (0.0.3) unstable; urgency=low
+
+ * CMakeList fix , fix according to change screen-engine API
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.3
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 27 Jul 2010 21:31:14 +0900
+
+aul-1 (0.0.2) unstable; urgency=low
+
+ * initial package upload
+ * Git: 165.213.180.234:/git/slp/pkgs/aul-1
+ * Tag: aul-1_0.0.2
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 27 Jul 2010 20:52:56 +0900
+
+aul-1 (0.0.1) unstable; urgency=low
+
+ * initial update
+
+ -- Kunhoon Baik <knhoon.baik@samsung.com> Tue, 27 Jul 2010 15:51:31 +0900
+
+
--- /dev/null
+Source: aul-1
+Section: devel
+Priority: extra
+Maintainer: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>, Yoonkyong Lee <yk6629.lee@samsung.com>, Youmin Ha <youmin.ha@samsung.com>, Kunhoon Baik <knhoon.baik@samsung.com>
+Build-Depends: debhelper (>= 5), libdbus-glib-1-dev, libsqlite3-dev, libx11-dev, libecore-dev, libbundle-dev, libail-0-dev, dlog-dev, libxdgmime-dev, libprivilege-control-dev, sqlite3, libapp-checker-dev, libapp-checker-server-dev, librua-dev, libslp-utilx-dev, libecore-dev, libecore-x, libevas-dev
+Standards-Version: 0.1.0
+
+Package: libaul-1
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, sqlite3
+Description: libaul-1 package
+
+Package: libaul-1-dev
+Section: libs
+Architecture: any
+Depends: libaul-1 (= ${Source-Version}), libdbus-glib-1-dev, libsqlite3-dev, libbundle-dev, libail-0-dev, dlog-dev, libxdgmime-dev, sqlite3
+Description: libaul-1 dev package
+
+Package: libaul-1-dbg
+Section: debug
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libaul-1 (= ${Source-Version})
+Description: libaul-1 dbg package
+
+Package: libaul-1-executable
+Section: libs
+Architecture: any
+Depends: libaul-1 (= ${Source-Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: libaul-1 executable package (aul_daemon(launchpad), aul_test)
+
--- /dev/null
+usr/bin
+usr/sbin
--- /dev/null
+@PREFIX@/include/*
+@PREFIX@/lib/pkgconfig/*.pc
--- /dev/null
+@PREFIX@/bin/aul_test
+@PREFIX@/bin/launch_app
+@PREFIX@/bin/launchpad_preloading_preinitializing_daemon
+@PREFIX@/bin/ac_daemon
+/etc/*
--- /dev/null
+#!/bin/sh
+if [ "${USER}" = "root" ]
+then
+ chown root:root /usr/bin/launchpad_preloading_preinitializing_daemon
+ chown root:root /etc/rc.d/init.d/launchpad_run
+fi
+
+chmod 755 /usr/bin/launchpad_preloading_preinitializing_daemon
+chmod 755 /etc/rc.d/init.d/launchpad_run
--- /dev/null
+@PREFIX@/lib/libaul.*\r
+@PREFIX@/bin/aul_service.sh\r
+@PREFIX@/bin/aul_service_test.sh\r
+@PREFIX@/bin/aul_mime.sh\r
+@PREFIX@/share/*\r
--- /dev/null
+#!/bin/sh
+
+mkdir -p /opt/dbspace
+sqlite3 /opt/dbspace/.mida.db < /opt/share/mida_db.sql
+rm -rf /opt/share/mida_db.sql
+
+if [ "${USER}" = "root" ]
+then
+ chown root:root /usr/lib/libaul.so.0.1.0
+ chown root:5000 /opt/dbspace/.mida.db
+ chown root:5000 /opt/dbspace/.mida.db-journal
+fi
+
+chmod 644 /usr/lib/libaul.so.0.1.0
+chmod 664 /opt/dbspace/.mida.db
+chmod 664 /opt/dbspace/.mida.db-journal
+
+#chmod 1777 /opt/share/miregex # Set directory to be writable for other accounts
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+export DH_VERBOSE=1
+
+CFLAGS += -Wall -g
+LDFLAGS ?=
+PREFIX ?= /usr
+DATADIR ?= /opt
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+
+LDFLAGS += -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed
+
+CMAKE_TMP_DIR = $(CURDIR)/cmake_tmp
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+ mkdir -p $(CMAKE_TMP_DIR);
+ cd $(CMAKE_TMP_DIR); CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" cmake .. -DCMAKE_INSTALL_PREFIX=$(PREFIX)
+
+ touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ cd $(CMAKE_TMP_DIR) && $(MAKE) all test
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ cat $$f > $${f%.in}; \
+ sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
+ sed -i -e "s#@DATADIR@#$(DATADIR)#g" $${f%.in}; \
+ done
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ rm -rf $(CMAKE_TMP_DIR)
+
+ for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
+ rm -f $${f%.in}; \
+ done
+
+ rm -rf include/pg-doxy/doxygen_output
+
+ rm -rf TC/results
+ rm -rf TC/tet_tmp_dir
+ cd TC/unit/ && make clean && cd ../../
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/wavplayer.
+ cd $(CMAKE_TMP_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
+
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/init.d
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc3.d
+ cp $(CURDIR)/launchpad_run $(CURDIR)/debian/tmp/etc/rc.d/init.d
+ ln -s ../init.d/launchpad_run $(CURDIR)/debian/tmp/etc/rc.d/rc3.d/S35launchpad_run
+ mkdir -p $(CURDIR)/debian/tmp/etc/rc.d/rc4.d
+ ln -s ../init.d/launchpad_run $(CURDIR)/debian/tmp/etc/rc.d/rc4.d/S80launchpad_run
+
+ #OUTDIR=$(CURDIR)/debian/tmp/opt/share/service $(CURDIR)/data/create_default_service.sh
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip --dbg-package=libaul-1-dbg
+ dh_compress
+ dh_fixperms
+# dh_perl
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+#ifdef PREEXEC_ACTIVATE
+
+#include <dlfcn.h>
+#include <glib.h>
+#define PREEXEC_FILE SHARE_PREFIX"/preexec_list.txt"
+
+static int preexec_initialized = 0;
+
+GSList *preexec_list = NULL;
+
+typedef struct _preexec_list_t {
+ char *pkg_type;
+ char *so_path;
+ int (*dl_do_pre_exe) (char *, char *);
+} preexec_list_t;
+
+static void __preexec_list_free()
+{
+ GSList *iter = NULL;
+ preexec_list_t *type_t;
+
+ for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
+ type_t = iter->data;
+ if (type_t) {
+ if (type_t->pkg_type)
+ free(type_t->pkg_type);
+ if (type_t->so_path)
+ free(type_t->so_path);
+ free(type_t);
+ }
+ }
+ g_slist_free(preexec_list);
+ preexec_initialized = 0;
+ return;
+}
+
+static inline void __preexec_init(int argc, char **argv)
+{
+ void *handle = NULL;
+ FILE *preexec_file;
+ char *saveptr = NULL;
+ char line[MAX_LOCAL_BUFSZ];
+ char *type = NULL;
+ char *sopath = NULL;
+ char *symbol = NULL;
+ int (*func) (char *, char *) = NULL;
+ preexec_list_t *type_t = NULL;
+
+ preexec_file = fopen(PREEXEC_FILE, "rt");
+ if (preexec_file == NULL) {
+ _E("no preexec\n");
+ return;
+ }
+
+ _D("preexec start\n");
+
+ while (fgets(line, MAX_LOCAL_BUFSZ, preexec_file) > 0) {
+ /* Parse each line */
+ if (line[0] == '#' || line[0] == '\0')
+ continue;
+
+ type = strtok_r(line, ":\f\n\r\t\v ", &saveptr);
+ if (type == NULL)
+ continue;
+ sopath = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
+ if (sopath == NULL)
+ continue;
+ symbol = strtok_r(NULL, ",\f\n\r\t\v ", &saveptr);
+ if (symbol == NULL)
+ continue;
+
+ type_t = (preexec_list_t *) calloc(1, sizeof(preexec_list_t));
+ if (type_t == NULL) {
+ _E("no available memory\n");
+ __preexec_list_free();
+ fclose(preexec_file);
+ return;
+ }
+
+ handle = dlopen(sopath, RTLD_NOW);
+ if (handle == NULL) {
+ free(type_t);
+ continue;
+ }
+ _D("preexec %s %s# - handle : %x\n", type, sopath, handle);
+
+ func = dlsym(handle, symbol);
+ if (func == NULL) {
+ _E("failed to get symbol type:%s path:%s\n",
+ type, sopath);
+ free(type_t);
+ dlclose(handle);
+ handle = NULL;
+ continue;
+ }
+
+ type_t->pkg_type = strdup(type);
+ if (type_t->pkg_type == NULL) {
+ _E("no available memory\n");
+ free(type_t);
+ __preexec_list_free();
+ fclose(preexec_file);
+ return;
+ }
+ type_t->so_path = strdup(sopath);
+ if (type_t->so_path == NULL) {
+ _E("no available memory\n");
+ free(type_t->pkg_type);
+ free(type_t);
+ __preexec_list_free();
+ fclose(preexec_file);
+ return;
+ }
+ type_t->dl_do_pre_exe = func;
+
+ preexec_list = g_slist_append(preexec_list, (void *)type_t);
+ }
+
+ fclose(preexec_file);
+ preexec_initialized = 1;
+}
+
+static inline void __preexec_run(const char *pkg_type, const char *pkg_name,
+ const char *app_path)
+{
+ GSList *iter = NULL;
+ preexec_list_t *type_t;
+
+ if (!preexec_initialized)
+ return;
+
+ for (iter = preexec_list; iter != NULL; iter = g_slist_next(iter)) {
+ type_t = iter->data;
+ if (type_t) {
+ if (!strcmp(pkg_type, type_t->pkg_type)) {
+ if (type_t->dl_do_pre_exe != NULL) {
+ type_t->dl_do_pre_exe((char *)pkg_name,
+ (char *)app_path);
+ _D("called dl_do_pre_exe() type: %s",
+ pkg_type);
+ } else {
+ _E("no symbol for this type: %s",
+ pkg_type);
+ }
+ }
+ }
+ }
+
+}
+
+#else
+
+static void __preexec_list_free()
+{
+}
+
+static inline void __preexec_init(int argc, char **argv)
+{
+}
+
+static inline void __preexec_run(const char *pkg_type, const char *pkg_name,
+ const char *app_path)
+{
+}
+
+#endif
--- /dev/null
+#preexec configuration
+##usage##
+#[type]: [preexec so path], [preexec symbol name]
+tpk: /usr/lib/libosp-env-config.so, do_pre_exec
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+/**
+
+ *
+ * @ingroup SLP_PG
+ * @defgroup AUL Application Utility Library
+
+
+@par AUL Programming Guide
+
+<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 Utility Library APIs.\n
+This document gives only programming guidelines to application engineers.
+
+<h2 class="pg"> Scope</h2>
+The scope of this document is limited to Samsung platform Application Utility Library API usage.
+@}
+
+@defgroup AUL_Architecture 1.Architecture
+@ingroup AUL
+@{
+<h1 class="pg">Application Utility Library Architecture</h1>
+<h2 class="pg"> Architecture overview</h2>
+Application Utility Library (AUL) is responsible for launching / resuming / terminating application. It support low-level API for it. AUL also support high-level API to launch default applications based on MIME types and URI(based on regular expression). It also provides the information of applications that are running.\n
+
+In single instance model, if a currently running application is requested to be launched again, the AUL sends the reset event to the application. \n
+
+Low-level AUL API(primitive APIs) expects the application to provide APN(application package name) it wishes to launch.\n Low-level interface used by AUL are as shown below. Unix Domain Socket is used to send events between launchpad deamon and applications.
+Launchpad deamon is responsible for setup default configuration of application like "setup authority", " setup application scale",... DB is used to store / retain default configuration of application.
+
+@image html low-level2.png "Low-level AUL diagram"
+
+High-level APIs support to launch based on MIME types(based on filename, URI, service name). This feature is abstraction of APN. Most develpers want to launch based on filename, URI, service name without knowing APN. Below is example list.
+ - When developer open browser appliction with "http://www.samsung.com".
+ - When developer open application with filename "/usr/share/myimage.png"
+ - When developer launching application with service name "camera" and service command "take_picture"
+
+Internally, AUL finds MIME type with given filename, URI, service name. Next, AUL find APN of default application from DB with associated MIME type. and then, AUL launch the application using primitive AUL APIs.
+
+@image html high-level2.png "High-Level AUL diagram"
+@}
+
+@defgroup AUL_Feature 2.Feature
+@ingroup AUL
+@{
+<h2 class="pg">Application Utility Library Features</h2>
+Application Utility Library has the following features:\n
+
+ - Launch/Resume/Terminate Application (Primitive APIs)
+ - It can launch an application that is not currently running.
+ - It sends reset/resume/terminate event if application is already running
+
+ - Application List or information
+ - It provides the list of applications that are running.
+ - It provides information of running applications
+
+ - MIME support (High-Level APIs)
+ - AUL can get MIME type associated with the file and content
+ - AUL can get the default application associated with the MIME type.
+ - AUL can launch default applications associated with the MIME(file or content) when AUL find default application.
+ - AUL automatically launch "application selection popup" when AUL don't find default application associated with the MIME(file or content)
+
+ - Application Service support (High-Level APIs)
+ - AUL can launch applications based on service name and service command
+@}
+
+@defgroup AUL_Use_Cases1 Launch/Resume/Terminate an Application
+@ingroup AUL_Use_Cases
+@{
+<h1 class="pg"> AUL features with sample code</h1>
+
+<h2 class="pg"> Launch/Resume/Terminate an application</h2>
+
+Caller application
+- LAUNCH or RESET request without return callback function
+- The first parameter(pkg_name) has to be registered through .desktop file.
+- The second parameter(bundle) give dictionary style's arguments to launched(callee) application.
+
+@code
+// the package name of this app is a "org.tizen.caller"
+#include <aul.h>
+#include <bundle.h>
+void launch_func()
+{
+ bundle* kb;
+ kb = bundle_create();
+ bundle_add(kb, "key1", "val1");
+ bundle_add(kb, "key2", "val2");
+ bundle_add(kb, "key3", "val3");
+ aul_launch_app("org.tizen.callee",kb);
+ bundle_free(kb);
+}
+@endcode
+
+- Return the application to the foreground
+- You might want to use aul_open_app when you need to resume,
+ e.g., get it back to foreground, an application
+- If the application is not running, the application will be launched.
+
+@code
+// the package name of this app is a "org.tizen.caller"
+#include <aul.h>
+void resume_func()
+{
+ aul_open_app("org.tizen.callee");
+}
+@endcode
+
+
+Callee application
+
+- Integated with Appcore
+- If you use Appcore Library, Aul library already was integrated.\n
+ You must implementation Appcore RESET , RESUME, TERMINATE handler.\n
+ This is example code. This is NOT guidance \n
+- If you want more information,SEE for AppCore document.
+
+@code
+//Callee application with AppCore
+
+#include <aul.h>
+#include <appcore-efl.h>
+#include <bundle.h>
+ :
+
+static int app_create(void *data)
+{
+ // initialize your app without argument
+ return 0;
+}
+
+static void _app_initialize_with_arg(bundle *b)
+{
+ // initialize your app with argument
+}
+
+//
+// called by window manager event
+// or called by aul_open_app
+// create your resume handler
+//
+static int app_resume(void *data){return 0;}
+static int app_pause(void *data) {return 0;}
+
+//
+// called by aul_terminate_api
+//
+static int app_terminate(void *data){return 0;}
+
+//
+// called by aul_launch_app or aul_launch_api_with_result
+// this is example code. create your reset handler
+//
+static int app_reset(bundle *b, void *data)
+{
+ char* mime_type;
+ if(bundle_get_val(ad->kb, AUL_K_ARGV0)) // when launch
+ _app_initialize_with_arg(b);
+ else{ // when receiving reset event
+ mime_type = bundle_get_val(b, AUL_K_MIME_TYPE);
+ if (!mime_type){
+ elm_win_activate(..);
+ return 0;
+ }else{
+ update_list(mime_type);
+ }
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ struct appcore_ops ops = {
+ .create = app_create,
+ .terminate = app_terminate,
+ .pause = app_pause,
+ .resume = app_resume,
+ .reset = app_reset,
+ };
+
+ return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+}
+@endcode
+
+
+- SET with AUL native handler
+- In special case, if you don't use Appcore library, this is aul callee's example
+
+@code
+// Callee application
+#include <aul.h>
+#include <bundle.h>
+#include <Ecore.h>
+
+static int aul_handler(aul_type type, bundle *kb,void* data)
+{
+ char* val1, *val2
+ switch(type){
+ case AUL_START:
+ // same to Appcore RESET callback
+ val1 = bundle_get_val(kb, "phone_number");
+ val2 = bundle_get_val(kb, "store");
+ break;
+ case AUL_RESUME:
+ // same to Appcore RESUME callback
+ break;
+ case AUL_TERMINATE:
+ // same to Appcore TERMINATE callback
+ break;
+ }
+ return 0;
+}
+
+int main(int argc, char** argv)
+{
+ ecore_init();
+
+ aul_launch_init(aul_handler,NULL);
+ // enable this if you want to handle at aul_handler when launch
+ aul_launch_argv_handler(argc, argv);
+
+ ecore_main_loop_begin(); // You must need ecore or glib mainloop
+ return 0;
+}
+@endcode
+@}
+
+@defgroup AUL_Use_Cases2 Get Running Application State
+@ingroup AUL_Use_Cases
+@{
+<h2 class="pg"> Get Running Application State </h2>
+
+- Getting running application list
+- This AUL function is used to get the list of all the applications that are currently running.
+
+@code
+#include <aul.h>
+
+int iterfunc(const aul_app_info* info, void* data)
+{
+ printf("package name: %s\n", info->pkg_name);
+ printf("running pid: %d\n", info->pid);
+ printf("application executable path: %s\n", info->app_path);
+ return 0;
+}
+
+int main (int argc, char **argv)
+{
+ aul_app_get_running_app_info(iterfunc,NULL);
+}
+@endcode
+
+- Get application running state
+- This AUL function is used to get application's state
+
+@code
+#include <aul.h>
+
+int main (int argc, char **argv)
+{
+ if(aul_app_is_running("org.tizen.app2"))
+ printf("application is running");
+}
+@endcode
+
+- Dead Handler (Set dead handler)
+- aul_listen_app_dead_signal track killed application.
+ For example, 3rd party application can register indicator icon at indicator service. When 3rd party application abnormally terminated after set icon at indicator, indicator service should collect garbage icon set by the application.
+
+@code
+#include <aul.h>
+
+int dead_tracker(int pid, void* data)
+{
+ printf("the application with %d pid was killed",pid);
+ return 0;
+}
+
+void set_dead_handler_func()
+{
+ aul_listen_app_dead_signal(dead_tracker,NULL);
+}
+@endcode
+@}
+
+@defgroup AUL_Use_Cases3 Launch Based on Mime Type
+@ingroup AUL_Use_Cases
+@{
+<h2 class="pg"> High Level APIs - launch based on mime type(filename, URI) </h2>
+
+- These AUL functions are used to launch the default application associated with the specified MIME extension. In addition, AUL provides functions to set/get the default application (package name) associated with a MIME type and functions to retrieve the MIME type associated with a specific file.
+
+- AUL launch default application associated with filename or url(or content)
+
+- AUL automatically launch "application selection popup" when AUL doesn't find default application.\n
+ App-Selector(application selection popup) shows list of application to process the file(or content).\n
+ User can select application from the list and open file with the application.\n
+ User can determine whether the selected application is set as default application or not.\n
+ If App-Selector doesn't find any application to process the file, App-Selector will show "Cannot get mimetype" or "Cannot find default application".
+
+@code
+// the package name of this app is a "org.tizen.caller"
+#include <aul.h>
+void func1(char* filename)
+{
+ aul_open_file(filename);
+}
+
+void func2(char* content)
+{
+ aul_open_content(content);
+}
+
+int main (int argc, char **argv)
+{
+ // launch the application to process 3gp.3gp file
+ func1("/opt/media/Videos/3gp.3gp");
+ // launch the application to process "http://www.samsung.com"
+ func2("http://www.samsung.com");
+}
+@endcode
+
+- We support primitive APIs for MIME operation
+ - aul_get_mime_from_content
+ - aul_get_mime_from_file
+ - aul_get_defapp_from_mime
+ - aul_set_defapp_with_mime
+
+This is example to launch MIME default applications using primitive APIs
+
+@code
+// the package name of this app is a "org.tizen.caller"
+
+#include <aul.h>
+#include <bundle.h>
+
+int main (int argc, char **argv)
+{
+ int ret;
+ char mimetype[128];
+ char defapp[128];
+ bundle *kb;
+
+ // get MIME type of "3gp.3gp"
+ if( aul_get_mime_from_file("3gp.3gp",mimetype,sizeof(mimetype)) <0)
+ return -1;
+ printf("3gp.3gp's mime type is %s",mimetype);
+
+ // get default application of the mimetype
+ if( aul_get_defapp_from_mime(mimetype,defapp,sizeof(defapp)) < 0)
+ return -1;
+ printf("%s types default application is %s\n", mimetype, defapp);
+
+ // Launch the default application with specific mime key
+ kb = bundle_create();
+ bundle_add(kb, AUL_K_MIME_TYPE, mimetype);
+ bundle_add(kb, AUL_K_MIME_CONTENT, "3gp.3gp");
+ aul_launch_app(defapp, kb);
+ bundle_free(kb);
+}
+@endcode
+
+
+- In callee, if you want to process specific MIME type
+ First, you must add mimetype field at desktop file
+ Second, you must process special key "AUL_K_MIME_TYPE", "AUL_K_MIME_CONTENT"
+
+@code
+// the package name of this app is a "org.tizen.callee"
+#include <aul.h>
+#include <bundle.h>
+
+// AppCore Reset Handler
+static int app_reset(bundle *b, void *data)
+{
+ char* mime_type;
+
+ mime_type = bundle_get_val(b, AUL_K_MIME_TYPE);
+ if (!mime_type)
+ return 0;
+ else
+ process_mime(mime_type, bundle_get_val(AUL_K_MIME_CONTENT));
+}
+@endcode
+@}
+
+@defgroup AUL_Use_Cases4 Launch Based on Service Name and Command
+@ingroup AUL_Use_Cases
+@{
+<h2 class="pg"> High Level APIs - launch based on service name and command </h2>
+
+- This AUL functions is used to launch default application based on service name and service command. In addition,AUL package support to set/get default application(package name) associated with service name and service command. This APIs also support to receive result from launched(requested) application.
+
+- Launch default application associated with service name and service command.
+- You can use aul_open_service when you launch an application associated with service name and service command
+- If the service support to receive result, you can add result callback function.
+- the API is asynchronous.(non-blocking API)
+
+@code
+// the package name of this app is a "org.tizen.caller"
+#include <aul.h>
+#include <bundle.h>
+void cb_func( bundle* kb, int reserved, void* data)
+{
+ char *id;
+ id = bundle_get_val(kb, "searched_id");
+ printf("searched id %s", id);
+}
+
+void service_launch_func()
+{
+ void* user_data;
+ bundle* kb;
+
+ user_data = (void*)strdup("my_priv_data");
+ kb = bundle_create();
+ bundle_add(kb, "storage_type", "SIM");
+ aul_open_appsvc("contact", "search", kb, cb_func, user_data);
+ bundle_free(kb);
+}
+@endcode
+
+- This is sample code to send result to caller in application(callee) given the service.
+- aul_send_service_result send result msg based on received bundle.
+
+@code
+// Callee application
+// the package name of this app is a "org.tizen.callee"
+
+#include <aul.h>
+#include <bundle.h>
+
+void send_result(bundle *recved_bundle, char* id)
+{
+ bundle* res_kb;
+ aul_create_result_bundle(recved_bundle,&res_kb);
+ bundle_add(res_kb, "searched_id", id);
+ aul_send_service_result(res_kb);
+ bundle_free(res_kb);
+}
+@endcode
+@}
+
+*/
+
+/**
+@addtogroup AUL
+@{
+ @defgroup AUL_Use_Cases Use Cases
+@}
+*/
+
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __APP_DBUS_H__
+#define __APP_DBUS_H__
+
+#include <glib.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#define AUL_DBUS_PATH "/aul/dbus_handler"
+#define AUL_DBUS_SIGNAL_INTERFACE "org.tizen.aul.signal"
+#define AUL_DBUS_APPDEAD_SIGNAL "app_dead"
+#define AUL_DBUS_APPLAUNCH_SIGNAL "app_launch"
+
+#endif
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __APP_PKT_H_
+#define __APP_PKT_H_
+
+#include <unistd.h>
+#define __USE_GNU
+#include <sys/socket.h>
+#include <linux/un.h>
+
+enum app_cmd {
+ APP_START,
+ APP_OPEN,
+ APP_RESUME,
+ APP_RESUME_BY_PID,
+ APP_TERM_BY_PID,
+ APP_RESULT,
+ APP_START_RES,
+ APP_CANCEL,
+ APP_KILL_BY_PID,
+ APP_ADD_HISTORY,
+ APP_RUNNING_INFO,
+ APP_RUNNING_INFO_RESULT,
+ APP_IS_RUNNING,
+ APP_KEY_EVENT,
+ APP_KEY_RESERVE,
+ APP_KEY_RELEASE,
+ APP_STATUS_UPDATE,
+ APP_RELEASED,
+ APP_RUNNING_LIST_UPDATE
+};
+
+#define AUL_SOCK_PREFIX "/tmp/alaunch"
+#define AUL_SOCK_MAXBUFF 65535
+#define LAUNCHPAD_PID -1
+#define WEB_LAUNCHPAD_PID -3
+#define ELOCALLAUNCH_ID 128
+
+typedef struct _app_pkt_t {
+ int cmd;
+ int len;
+ unsigned char data[1];
+} app_pkt_t;
+
+int __create_server_sock(int pid);
+int __create_client_sock(int pid);
+int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen);
+app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr);
+app_pkt_t *__app_send_cmd_with_result(int pid, int cmd);
+
+#endif
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __AUL_H__
+#define __AUL_H__
+
+#include <errno.h>
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @mainpage
+ *
+ * This is new version of Application Utility Library
+ *
+ * Almost function's input param is application package name(APN).\n
+ * APN is application package name which is set by developer.\n
+ * In case of in-house application, prefix is org.tizen.\n
+ * It is different from debian package name.\n
+ *
+ * - Debian Package Name : Name which is managed by package manager
+ * - Application Package Name : Name which is used by AUL
+ * - Execution Path : real program executable path
+ */
+
+/**
+ * @open
+ * @ingroup APPLICATION_FRAMEWORK
+ * @defgroup aul Application Utility Library
+ * @{
+ */
+
+
+/**
+ * @file aul.h
+ * @brief Application Utility Library header
+ *
+ * Patched by Knhoon Baik <knhoon.baik@samsung.com>
+ * Patched by Youmin Ha <youmin.ha@samsung.com>
+ */
+
+/**
+ * @addtogroup aul
+ * @{
+ */
+
+/**
+ * @brief Return values in AUL.
+ */
+typedef enum _aul_return_val {
+ AUL_R_LOCAL = -7, /**< Launch by himself */
+ AUL_R_ETIMEOUT = -6, /**< Timeout */
+ AUL_R_ECANCELED = -5, /**< Operation canceled */
+ AUL_R_EINVAL = -4, /**< Invalid argument */
+ AUL_R_ECOMM = -3, /**< Comunication Error */
+ AUL_R_ENOINIT = -2, /**< AUL handler NOT initialized */
+ AUL_R_ERROR = -1, /**< General error */
+ AUL_R_OK = 0 /**< General success */
+}aul_return_val;
+
+enum app_status {
+ STATUS_LAUNCHING,
+ STATUS_CREATED,
+ STATUS_FOCUS,
+ STATUS_VISIBLE,
+ STATUS_BG,
+ STATUS_DYING,
+ STATUS_HOME
+};
+
+/** @} */
+
+/**
+ * @defgroup aul_launch Primitive APIs to launch/resume/terminate application
+ * @ingroup aul
+ * @brief
+ * APIs to launch/resume/terminate application
+ * - Launch application based on application package name
+ * - Resume application based on application package name
+ * - Resume application based on pid (required root or inhouse permisssion)
+ * - Terminate application base on pid (required root or inhouse permission)
+ *
+ * AUL internal information
+ * - AUL grant pid, gid to launched application for security
+ * - AUL send RESET/RESUME/TERM event for running application in case of single instance
+ * - AUL set application enviroment based on desktop entry
+ * - AUL support single instance / multi instance
+ * - AUL support application data exchange format (bundle)
+ */
+
+/**
+ * @addtogroup aul_launch
+ * @{
+ */
+
+typedef enum _aul_type{
+ AUL_START,
+ AUL_RESUME,
+ AUL_TERMINATE
+}aul_type;
+
+/** AUL internal private key */
+#define AUL_K_PKG_NAME "__AUL_PKG_NAME__"
+/** AUL internal private key */
+#define AUL_K_WAIT_RESULT "__AUL_WAIT_RESULT__"
+/** AUL internal private key */
+#define AUL_K_SEND_RESULT "__AUL_SEND_RESULT__"
+/** AUL internal private key */
+#define AUL_K_TASK_MANAGE "__AUL_TASK_MANAGE__"
+/** AUL internal private key */
+#define AUL_K_APP_TYPE "__AUL_APP_TYPE__"
+/** AUL internal private key - To check original caller's identity */
+#define AUL_K_ORG_CALLER_PID "__AUL_ORG_CALLER_PID__"
+/** AUL internal private key - To check forwarded callee app's pid */
+#define AUL_K_FWD_CALLEE_PID "__AUL_FWD_CALLEE_PID__"
+
+/** AUL public key - To check caller's secuirty */
+#define AUL_K_CALLER_PID "__AUL_CALLER_PID__"
+/** AUL public key - To check callee's secuirty */
+#define AUL_K_CALLEE_PID "__AUL_CALLEE_PID__"
+
+/** AUL public key - To find argv0 */
+#define AUL_K_ARGV0 "__AUL_ARGV0__"
+/** AUL public key - To measure launching time */
+#define AUL_K_STARTTIME "__AUL_STARTTIME__"
+
+/** AUL public key - To support launching based on mime type */
+#define AUL_K_MIME_TYPE "__AUL_MIME_TYPE__"
+/** AUL public key - To support launching based on mime type */
+#define AUL_K_UNALIASED_MIME_TYPE "__AUL_UNALIASED_MIME_TYPE__"
+/** AUL public key - To support launching based on mime type */
+#define AUL_K_MIME_CONTENT "__AUL_MIME_CONTENT__"
+
+/** AUL public key - To support launching based on service */
+#define AUL_K_SERVICE_NAME "__AUL_SERVICE_NAME__"
+
+/** AUL public key - To force launch app selector instead of lauchingn default app */
+#define AUL_K_FORCE_LAUNCH_APP_SELECTOR "__AUL_FORCE_LAUNCH_APP_SELECTOR__"
+
+/** AUL public key - To support SDK */
+#define AUL_K_SDK "__AUL_SDK__"
+
+/** AUL public key - To support Media key */
+#define AUL_K_MULTI_KEY "__AUL_MULTI_KEY__"
+/** AUL public key - To support Media key */
+#define AUL_K_MULTI_KEY_EVENT "__AUL_MULTI_KEY_EVENT__"
+
+/** AUL public bundle value - To support Media key*/
+#define AUL_V_KEY_PRESSED "__AUL_KEY_PRESSED__"
+/** AUL public bundle value - To support Media key*/
+#define AUL_V_KEY_RELEASED "__AUL_KEY_RELEASED__"
+
+/** AUL internal private key */
+#define AUL_K_EXEC "__AUL_EXEC__"
+/** AUL internal private key */
+#define AUL_K_MULTIPLE "__AUL_MULTIPLE__"
+/** AUL internal private key */
+#define AUL_K_PACKAGETYPE "__AUL_PACKAGETYPE__"
+/** AUL internal private key */
+#define AUL_K_HWACC "__AUL_HWACC__"
+
+
+/** AUL internal private key */
+#define AUL_K_APPID "__AUL_APPID__"
+/** AUL internal private key */
+#define AUL_K_PID "__AUL_PID__"
+
+
+
+/**
+ * @brief This is callback function for aul_launch_init
+ * @param[in] type event's type received from system
+ * @param[in] b In case of RESET events, bundle which is received from peer
+ * @param[in] data user-supplied data
+ */
+typedef int (*aul_handler_fn) (aul_type type, bundle * b, void *data);
+
+/**
+ * @par Description:
+ * This API install your AUL handler and setup AUL internal connection.
+ * @par Purpose:
+ * AUL receive START(RESET), RESUME, TERMINATE events from system.\n
+ * This API use to handle the events. \n
+ * @par Typical use case:
+ * In general, you need not use this API.
+ * If you use AppCore, you should NOT use this API.
+ * AppCore will set default aul_handler.
+ *
+ * @param[in] handler aul main callback handler function
+ * @param[in] data user-supplied data for start_handler
+ * @return 0 if success, negative value(<0) if fail\n
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ECANCELD - aul handler was installed already by others
+ * @retval AUL_R_ECOMM - error to create internal ipc
+ * @retval AUL_R_ERROR - error to attach glib main loop or ecore main loop
+ *
+ * @warning If you use AppCore, you should NOT use this API.\n
+ * You need glib main loop or ecore main loop.\n
+ * @pre
+ * you must have aul handler to use this API.
+ * aul_luanch_init register aul handler.
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * static int aul_handler(aul_type type, bundle *kb,void *data)
+ * {
+ * switch(type)
+ * {
+ * case AUL_START:
+ * // process RESET event
+ * break;
+ * case AUL_RESUME:
+ * // process RESUME event
+ * break;
+ * case AUL_TERMINATE:
+ * // preocess TERMINATE event
+ * break;
+ * }
+ * return 0;
+ * }
+ *
+ * int main(int argc, char **argv)
+ * {
+ * ecore_init();
+ * aul_launch_init(aul_handler,NULL);
+ * aul_launch_argv_handler(argc, argv);
+ * ecore_main_loop_begin();
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+*/
+int aul_launch_init(aul_handler_fn handler, void *data);
+
+/**
+ * @par Description:
+ * This API create internal RESET events with given argc, argv \n
+ * @par Purpose:
+ * This API's purpose is to generate reset event.
+ * If you want to generate local RESET events with argument vector format, use this API
+ * @par Typical use case:
+ * In general, you need not use this API.
+ * AppCore use this API to create internal reset event.
+ *
+ * @param[in] argc # of args
+ * @param[in] argv list of arg strings
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ENOINIT - aul handler was NOT yet installed
+ * @retval AUL_R_ECANCLED - error to create internal bundle with given argc,argv.
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * you must have aul handler to use this API.
+ * aul_luanch_init register aul handler.
+ * @post
+ * None
+ * @see
+ * aul_launch_init
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int send_local_reset_event()
+ * {
+ * int argc=3;
+ * char* argv[4];
+ * argv[0] = "local.app";
+ * argv[1] = "event_type";
+ * argv[2] = "my_reset";
+ * argv[3] = NULL;
+ * aul_launch_argv_handler(argc,argv);
+ * }
+ *
+ * @endcode
+ * @remark
+ * If you use AppCore, you NEED NOT use this API.
+*/
+int aul_launch_argv_handler(int argc, char **argv);
+
+/**
+ * @par Description:
+ * This API creates internal RESET events with given bundle \n
+ * @par Purpose:
+ * This API's purpose is to generate reset event.
+ * If you want to generate local RESET events with argument vector format, first use
+ * bundle_import_from_argv to create a bundle from the argument vector and then use this API
+ * Eventually, this API will replace aul_launch_argv_handler().
+ * @par Typical use case:
+ * In general, you need not use this API.
+ * AppCore use this API to create internal reset event.
+ *
+ * @param[in] b bundle
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ENOINIT - aul handler was NOT yet installed
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * you must have aul handler to use this API.
+ * aul_luanch_init register aul handler.
+ * @post
+ * None
+ * @see
+ * aul_launch_init, bundle_import_from_argv
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int send_local_reset_event()
+ * {
+ * bundle* b;
+ * int argc=3;
+ * char* argv[4];
+ * argv[0] = "local.app";
+ * argv[1] = "event_type";
+ * argv[2] = "my_reset";
+ * argv[3] = NULL;
+ *
+ * b = bundle_import_from_argv(argc,argv);
+ * aul_launch_local(b);
+ * }
+ *
+ * @endcode
+ * @remark
+ * If you use AppCore, you NEED NOT to use this API.
+*/
+int aul_launch_local(bundle *b);
+
+/**
+ * @par Description:
+ * This API launches application with the given bundle.
+ * If the application is not running or a multiple-instance one, this API launches with the given bundle.
+ * If the application is running, this API sends a RESET event to the App.
+ * While the application is running, if the application cannot receive the RESET event,
+ * this API returns a general error(AUL_R_ERROR).\n
+ * @par Purpose:
+ * This API is for caller.
+ * This API's purpose is to launch/reset application with given bundle.
+ * @par Typical use case:
+ * If you know the target application's pkgname and bundle types,
+ * you can use this API to launch/reset the application.
+ *
+ * @param[in] pkgname package name to be run as callee
+ * @param[in] kb bundle to be passed to callee
+ * @return callee's pid if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invaild package name
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_open_app
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int launch_inhouse_contact_app()
+ * {
+ * bundle *b;
+ * b = bundle_create();
+ * bundle_add(b,"type","SIM");
+ * aul_launch_app("org.tizen.contact",b);
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ */
+int aul_launch_app(const char *appid, bundle *kb);
+
+/**
+ * @par Description:
+ * This API launches application, as menu screen launches the app.
+ * Thus, if the applocation is running, this API sends a RESUME event to the app.
+ * If the application is not running, this API launches the app.
+ * While the application is running, if the application cannot receive the RESUME event,
+ * AUL tries to raise the application's default window.
+ *
+ * @par Purpose:
+ * This API is for caller.
+ * This API's purpose is to resume/launch application
+ * @par Typical use case:
+ * If you only want to show application with previous state or default state, Use this API.
+ *
+ * @param[in] pkgname package name to be resume as callee
+ * @return callee's pid if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invaild package name
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_launch_app, aul_app_is_running, aul_resume_pid
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int open_inhouse_contact_app()
+ * {
+ * if(aul_app_is_running("org.tizen.contact"))
+ * aul_open_app("org.tizen.contact");
+ * }
+ *
+ * @endcode
+ * @remark
+ * If you don't want to launch the app,
+ * you should check app's running state with aul_app_is_running.
+ * This API will launch the application if the application is not running.
+*/
+int aul_open_app(const char *appid);
+
+/**
+ * @par Description:
+ * This API trigger to resume application
+ * If the application is running, this API send a resume event to the App.
+ * If the application is not running, this API returns fail.
+ * Although the application is running, if the application cannot receive resume event,
+ * AUL try to raise the application's default windows.
+ * @par Purpose:
+ * This API is for caller.
+ * This API's purpose is to send resume event.
+ * @par Typical use case:
+ * If you only want to show application with previous state or default state, Use this API.
+ *
+ * @param[in] pkgname package name to be resume as callee
+ * @return callee's pid if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invaild package name
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_launch_app, aul_app_is_running, aul_resume_pid
+ * @deprecated
+ * This function will be deprecated. Use aul_open_add() instead.
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int resume_inhouse_contact_app()
+ * {
+ * if(aul_app_is_running("org.tizen.contact"))
+ * aul_resume_app("org.tizen.contact");
+ * }
+ *
+ * @endcode
+ * @remark
+ * If you don't want to launch the app,
+ * you should check app's running state with aul_app_is_running.
+ * This API will launch the application if the application is not running.
+ * If you want to only resume without launching in multiple instance application model,
+ * you should use aul_resume_pid.
+*/
+int aul_resume_app(const char *appid);
+
+/**
+ * @par Description:
+ * This API trigger to resume application
+ * If the application is running, this API send a resume event to the App.
+ * If the application is not running, this API return AUL_R_ERROR.
+ * Although the application is running, if the application cannot receive resume event,
+ * AUL try to raise the application's default windows.
+ * @par Purpose:
+ * This API is for caller.
+ * This API's purpose is to send resume event.
+ * @par Typical use case:
+ * In multiple application model, If you want to only resume specific application, Use this API
+ *
+ * @param[in] pid application's pid to be resumed
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invaild pid
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error (include application is not running)
+ * @warning This API need to require root or inhouse permisssion \n
+ * If you have not the permission, this API return AUL_R_ERROR. \n
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_launch_app
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int iterfunc(const aul_app_info *info, void *data)
+ * {
+ * if(strcmp(info->pkg_name,"org.tizen.contact")==0)
+ * aul_resume_pid(info->pid);
+ * }
+ *
+ * int iterate_running_apps()
+ * {
+ * return aul_app_get_running_app_info(iterfunc,NULL);
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+*/
+int aul_resume_pid(int pid);
+
+/**
+ * @par Description:
+ * This API trigger to terminate application
+ *
+ * If the application is running, this API send a terminate event to the App. \n
+ * If the app cannot receive the event, AUL kill forcely the application.\n
+ * @par Purpose:
+ * This API's purpose is to kill application
+ * @par Typical use case:
+ * In general, Application like Task Manager use this API.
+ *
+ * This API need to require root or inhouse permisssion. \n
+ *
+ * @param[in] pid application's pid to be terminated
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invaild pid
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error
+ * @warning This API need to require root or inhouse permisssion. \n
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int iterfunc(const aul_app_info *info, void *data)
+ * {
+ * if(strcmp(info->pkg_name,"org.tizen.contact")==0)
+ * aul_terminate_pid(info->pid);
+ * }
+ *
+ * int iterate_running_apps()
+ * {
+ * return aul_app_get_running_app_info(iterfunc,NULL);
+ * }
+ *
+ * @endcode
+ * @remark
+ * If you have not the permission, this API return AUL_R_ERROR. \n
+*/
+int aul_terminate_pid(int pid);
+
+/** @} */
+
+/**
+ * @defgroup aul_info Helper APIs to get running application information
+ * @ingroup aul
+ * @brief
+ * API to get running application information (state, executable path, ..)
+ * - get application package name from pid
+ * - get application running state
+ * - get application list of runnning applications
+ */
+
+/**
+ * @addtogroup aul_info
+ * @{
+ */
+
+/**
+ *@brief Running application's information structure retrieved by AUL
+ */
+typedef struct _aul_app_info {
+ int pid; /**< app's pid if running*/
+ char* pkg_name; /**< application id */
+ char* app_path; /**< application excutable path */
+ char* appid;
+} aul_app_info;
+
+/**
+ * @brief iterator function running with aul_app_get_running_app_info
+ * @param[out] ainfo aul_app_info retreived by aul_app_get_running_app_info
+ * @param[out] data user-supplied data
+*/
+typedef int (*aul_app_info_iter_fn)(const aul_app_info *ainfo, void *data);
+
+/**
+ * @par Description:
+ * This API ask a application is running by application package name.
+ * @par Purpose:
+ * To know whether some application is running or not, use this API
+ * @par Typical use case:
+ * For example, If you want to know browser application running,
+ * you can check it by using this API.
+ *
+ * @param[in] pkgname application package name
+ * @return true / false
+ * @retval 1 app_name is running now.
+ * @retval 0 app_name is NOT running now.
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ *
+ * int is_running_browser_app()
+ * {
+ * return aul_app_is_running("org.tizen.browser");
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+*
+*/
+int aul_app_is_running(const char *appid);
+
+/**
+ * @par Description:
+ * This API use to get running application list.
+ * This API call iter_fn with each aul_app_info of running apps when running application is found.
+ * @par Purpose:
+ * If you want to get running application list, use this API
+ * This API give you running applications which has SLP desktop file.
+ * @par Typical use case:
+ * In general, this API is used by task manager appllication. (running application list viewer)
+ *
+ * @param[in] iter_fn iterator function
+ * @param[in] data user-supplied data for iter_fn
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ERROR - internal error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ *
+ * int iterfunc(const aul_app_info* info, void* data)
+ * {
+ * printf("\t==========================\n");
+ * printf("\t pkg_name: %s\n", info->appid);
+ * printf("\t app_path: %s\n", info->app_path);
+ * printf("\t running pid: %d\n", info->pid);
+ * printf("\t==========================\n");
+ * return 0;
+ * }
+ *
+ * int iterate_running_apps()
+ * {
+ * return aul_app_get_running_app_info(iterfunc,NULL);
+ * }
+ *
+ * @endcode
+ * @remark
+ * This API should use if you want to know running application which has desktop files.
+ * If you want to get all process list, you must iterate process information by using proc filesystem
+ * Or, If you want to get all window list, you must iterate XWindows by using XWindow APIs
+ */
+int aul_app_get_running_app_info(aul_app_info_iter_fn iter_fn, void *data);
+
+/**
+ * @par Description:
+ * This API get application package name by pid
+ * @par Purpose:
+ * If you want to get package name of running application, use this API
+ * @par Typical use case:
+ * In general, You can use this API when you want to know caller's information.
+ *
+ * @param[in] pid given pid
+ * @param[out] pkgname pkgname to be get
+ * @param[in] len length of pkgname
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ERROR - no such a package name
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * static int app_reset(bundle *b, void *data)
+ * {
+ * int pid;
+ * char appname[255];
+ *
+ * pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
+ * aul_app_get_pkgname_bypid(pid, appname, sizeof(appname));
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+*/
+int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len);
+
+/**
+ * @par Description:
+ * This API get application appid by pid
+ * @par Purpose:
+ * If you want to get appid of running application, use this API
+ * @par Typical use case:
+ * In general, You can use this API when you want to know caller's information.
+ *
+ * @param[in] pid given pid
+ * @param[out] appid application id
+ * @param[in] len length of pkgname
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ERROR - no such a appid
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * static int app_reset(bundle *b, void *data)
+ * {
+ * int pid;
+ * char appid[255];
+ *
+ * pid = atoi(bundle_get_val(b,AUL_K_CALLER_PID));
+ * aul_app_get_appid_bypid(pid, appid, sizeof(appid));
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+*/
+int aul_app_get_appid_bypid(int pid, char *appid, int len);
+
+
+/** @} */
+
+/**
+ * @defgroup aul_mime High-level APIs to launch default application based on mime type
+ * @ingroup aul
+ * @brief
+ * AUL High-level APIs based on mime type
+ *
+ * These APIs provide two functionality\n
+ *
+ * -# To launch default application to open a file based on its MIME type \n
+ * For example, you can launch the default video player to open .mp4 files
+ * or launch the default browser to open HTML files \n
+ * -# To launch default application to process given content \n
+ * For example, you can launch the default e-mail application to process
+ * "nice@samsung.com" e-mail address.
+ */
+
+/**
+ * @addtogroup aul_mime
+ * @{
+ */
+
+/**
+ * @par Description:
+ * This API launch application associated with given filename
+ * @par Purpose:
+ * This API is for caller.
+ * This API launch application based on mime type.
+ * This API find mime_type associated with file name,
+ * and then find default app associated with found mime_type
+ * and then launch the app with filename argument.
+ * @par Typical use case:
+ * You can launch application to process given filename.
+ * That is, Even if you don't know the specific application's pkgname,
+ * you can launch the applicaiton processing given filename .
+ * For example, If you want to process image file, you can simply launch image viewer.
+ * At that time, you can use this APIs like aul_open_file("myimage.jpg");
+ *
+ * @param[in] filename filename
+ * @return callee's pid or 0 if success, negative value if fail\n
+ * (when no found default app, return 0)
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(filename)
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ *
+ * int view_image_file(char *filename)
+ * {
+ * aul_open_file(filename);
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_open_file(const char* filename);
+
+/**
+ * @par Description:
+ * This API launch application associated with given specific mimetype
+ * @par Purpose:
+ * This API is for caller.
+ * This API launch application based on mime type like aul_open_file API.
+ * But, This API don't find mime_type associated with file name.
+ * This API use mimetype given by user. By using given mimetype, find default application.
+ * and then launch the app with filename argument.
+ * @par Typical use case:
+ * Some files cannot extract exact mimetype automatically.
+ * For example, To know mime type of files with DRM lock, first we should unlock DRM file.
+ * In this case, You can use this API.
+ * First, unlock DRM file, and extract mimetype from unlock file by using aul_get_mime_from_file,
+ * and then, use this API with DRM file and extracted mime type.
+ *
+ * @param[in] filename filename
+ * @param[in] mimetype specific mimetype
+ * @return callee's pid or 0 if success, negative value if fail\n
+ * (when no found default app, return 0)
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(filename,mimetype)
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_open_file, aul_get_mime_from_file
+ * @code
+ * #include <aul.h>
+ *
+ * int view_drm_image_file(char *drm_filename)
+ * {
+ * char* mimetype;
+ * // you must implement this function
+ * mimetype = get_mimetype_from_drmfile(drm_filename);
+ *
+ * aul_open_file_with_mimetype(drm_filename,mimetype);
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ */
+int aul_open_file_with_mimetype(const char *filename, const char *mimetype);
+
+/**
+ * @par Description:
+ * This API launch application associated with content like "http://www.samsung.com"
+ * @par Purpose:
+ * This API is for caller.
+ * This API launch application based on mime type.
+ * This API find mime_type associated with content,
+ * and then find default app associated with found mime_type,
+ * and then launch the app with content argument.
+ * @par Typical use case:
+ * You can launch application to process given content.
+ * That is, Even if you don't know the specific application's pkgname,
+ * you can launch the applicaiton processing given content.
+ * For example, If you want to process URL "http://www.samsung.com",
+ * you can simply launch browser.
+ * At that time, you can use this APIs like aul_open_content("http://www.samsung.com");
+ *
+ * @param[in] content content
+ * @return callee's pid or 0 if success, negative value if fail\n
+ * (when no found default app, return 0)
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(content)
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error or no found mimetype
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ *
+ * int view_url(char *url)
+ * {
+ * aul_open_content(url);
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_open_content(const char* content);
+
+/**
+ * @par Description:
+ * This API get the default application(appid) associated with MIME type
+ * @par Purpose:
+ * This API use to get default application associteted with mimetype
+ * In general, Setting Application need this API.
+ * @par Typical use case:
+ * Setting Application show mapping of default application / mimetype
+ *
+ * @param[in] mimetype a mime type
+ * @param[out] defapp a application appid of the app
+ * @param[in] len length of defapp
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(mimetype)
+ * @retval AUL_R_ERROR - general error or no found mimetype
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_set_defapp_with_mime
+ * @code
+ * #include <aul.h>
+ *
+ * void get_text_html_defapp()
+ * {
+ * char appname[255];
+ * aul_get_defapp_from_mime("text/html",appname,sizeof(appname));
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len);
+
+/**
+ * @par Description:
+ * This API set the default application(appid) associated with MIME type
+ * @par Purpose:
+ * This API use to change default application associteted with mimetype
+ * In general, Setting Application or Installer need this API.
+ * @par Typical use case:
+ * Default Application associated with mimetype can be changed by Setting Application or installer
+ * So, application to process specific mimetype can be substituted.
+ *
+ * @param[in] mimetype a mime type
+ * @param[in] defapp a application appid of the app to be set
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(mimetype)
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_get_defapp_from_mime
+ * @code
+ * #include <aul.h>
+ *
+ * void set_text_html_defapp()
+ * {
+ * aul_set_defapp_with_mime("text/html","org.tizen.browser");
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+*/
+int aul_set_defapp_with_mime(const char *mimetype, const char *defapp);
+
+/**
+ * @par Description:
+ * This API get the mimetype associated with filename
+ * @par Purpose:
+ * This API use to get mimetype associteted with given filename
+ * In general, This API use when you want to know only mimetype given filename.
+ * @par Typical use case:
+ * For example, In trasfering data through bluetooth,
+ * additional information like mimetype should be added.
+ * In such situation, You can get mimetype by using this API.
+ *
+ * @param[in] filename file name
+ * @param[out] mimetype a mime type
+ * @param[in] len length of mimetype
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(filename)
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ *
+ * void get_mimetype()
+ * {
+ * char mimetype[255];
+ * aul_get_mime_from_file("image.jpg",mimetype,sizeof(mimetype));
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ */
+int aul_get_mime_from_file(const char *filename, char *mimetype, int len);
+
+/**
+ * @par Description:
+ * This API get the mimetype associated with given content
+ * @par Purpose:
+ * This API use to get mimetype associteted with given content
+ * In general, This API use when you want to know only mimetype given content
+ * @par Typical use case:
+ * For example, In trasfering data through bluetooth,
+ * additional information like mimetype should be added.
+ * In such situation, You can get mimetype by using this API.
+ *
+ * @param[in] content content string like "011-0000-0000"
+ * @param[out] mimetype a mime type
+ * @param[in] len length of mimetype
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(content)
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ *
+ * void get_mimetype()
+ * {
+ * char mimetype[255];
+ * aul_get_mime_from_content("http://www.samsung.com",mimetype,sizeof(mimetype));
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+*/
+int aul_get_mime_from_content(const char *content, char *mimetype, int len);
+
+/**
+ * @par Description:
+ * This API get the icon's name associated with given mimetype
+ * @par Purpose:
+ * This API use to get icon's name associteted with given mimetype
+ * @par Typical use case:
+ * If you want to show mimetype's icon, use this API.
+ *
+ * @param[in] mimetype a mime type
+ * @param[out] iconname icon's name
+ * @param[in] len length of iconname
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(content)
+ * @retval AUL_R_ERROR - general error (no such mime type)
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ *
+ * void get_mime_icon()
+ * {
+ * char icon[255];
+ * aul_get_mime_icon("text/html",icon,sizeof(icon));
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ */
+int aul_get_mime_icon(const char *mimetype, char *iconname, int len);
+
+/**
+ * @par Description:
+ * This API get the extensions associated with given mimetype
+ * @par Purpose:
+ * This API use to get extensions associteted with given mimetype
+ * @par Typical use case:
+ * In general, user is not familiar with mimetype(text/html),
+ * user is familiar with extenstions(*.html, *.htm)
+ * So, To show mimetype information to user, use this API
+ *
+ * @param[in] mimetype a mime type
+ * @param[out] extlist extentions (ex> mpeg,mpg,mpe)
+ * @param[in] len length of extlist
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(mimetype)
+ * @retval AUL_R_ERROR - general error (no mimetype or no extenstion)
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_get_mime_description
+ * @code
+ * #include <aul.h>
+ *
+ * void get_extension()
+ * {
+ * char extlist[255];
+ * aul_get_mime_extension("text/html",extlist,sizeof(extlist));
+ * }
+ *
+ * @endcode
+ * @remark
+ * Some mimetype don't have extension.
+ * In that case, You can use aul_get_mime_description.
+ *
+*/
+int aul_get_mime_extension(const char *mimetype, char *extlist, int len);
+
+/**
+ * @par Description:
+ * This API get the description associated with given mimetype
+ * @par Purpose:
+ * This API use to get description associteted with given mimetype
+ * @par Typical use case:
+ * In general, user is not familiar with mimetype(text/html),
+ * user is familiar with well-knowing information like extenstions(*.html, *.htm)
+ * But, some mimetype don't have extenstion.
+ * At that time,to show mimetype information to user, use this API
+ *
+ * @param[in] mimetype a mime type
+ * @param[out] desc description (ex> Call client)
+ * @param[in] len length of desc
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(mimetype)
+ * @retval AUL_R_ERROR - general error (no mimetype or no descrition)
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_get_mime_extension
+ * @code
+ * #include <aul.h>
+ *
+ * void get_information_from_mime()
+ * {
+ * char info[255];
+ * if(aul_get_mime_extension("text/html",info,sizeof(info))<0){
+ * aul_get_mime_description("text/html",info,sizeof(info));
+ * }
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ */
+int aul_get_mime_description(const char *mimetype, char *desc, int len);
+
+/************************************************************************************************/
+/* Example of aul_open_content or aul_open_file */
+/* voice call , browser , docview , image viewer , audio player, video player */
+/* */
+/* voice call - aul_open_content("callto://011-1111-1111"); */
+/* browser - aul_open_content("http://www.naver.com"); */
+/* - aul_open_file("/opt/share/index.html"); */
+/* docview - aul_open_file("/opt/share/word.pdf"); */
+/* image view - aul_open_file("/opt/share/image.jpg"); */
+/* audio play - aul_open_file("/opt/share/audio.mp3"); */
+/* video play - aul_open_file("/opt/share/video.mpg"); */
+/************************************************************************************************/
+
+/** @} */
+
+/**
+ * @defgroup aul_service High-level APIs to launch applications based on service.
+ * @ingroup aul
+ * @brief
+ * AUL High-level APIs based on service
+ *
+ * This is Request/Response mechanism based on AUL like DBUS service call with auto-activation.\n
+ * We recommend this APIs for requesting application service like camera application service (take_picture)
+ * But, You can use other mechanism like DBUS service or your own internal IPC
+ *
+ * - Caller\n
+ * Launch application based on service \n
+ * If application is not running, AUL requests to reset the event.\n
+ * Application can wait result with callback function.
+ *
+ * - Callee\n
+ * After callee performs the requested operation, callee sends the result back, if necessary.\n
+ *
+ */
+
+/**
+ * @addtogroup aul_service
+ * @{
+ */
+
+/**
+ * @brief aul_service_res_fn is service result function
+ * @param[out] b result bundle
+ * @param[out] data user-supplied data
+*/
+typedef void (*aul_service_res_fn)(bundle *b, int reserved, void *user_data);
+
+/**
+ * @par Description:
+ * This API launch application based on service.
+ * @par Purpose:
+ * This API is for caller.
+ * This API launch application based on service name.
+ * This API find default application associated with service name.
+ * and then launch the application with given bundle.
+ * @par Typical use case:
+ * You can launch application provided the service if you know service name.
+ * That is, even if you don't know the specific application's pkgname,
+ * you can launch the applicaiton by requesting the service.
+ * For example, If you want to take a picture in your app, you can simply launch camera application.
+ * At that time, you can use this API like aul_open_service(TAKE_PICTURE_SVC,..);
+ *
+ *
+ * @param[in] svcname service name to launch as callee
+ * @param[in] b bundle to be passed to callee
+ * @param[in] cbfunc result callback function
+ * @param[in] data user-supplied data passed to callback function
+ * @return callee's pid if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invaild service name
+ * @retval AUL_R_ENOINIT - you must initilize aul library with aul_launch_init
+ * @retval AUL_R_ECOM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * None
+ * @code
+ * #include <aul.h>
+ * #include <aul_service.h>
+ * #include <bundle.h>
+ *
+ * void res_func(bundle *b, int reserved, void *user_data)
+ * {
+ * // process result bundle
+ * }
+ *
+ * int create_camera_view()
+ * {
+ * aul_open_service(TAKE_PICTURE_SVC, NULL, res_func, NULL);
+ * }
+ *
+ * @endcode
+ * @remark
+ * This API can wait result (asynchronous).
+ * To see kinds of default service provided by platform, see "aul_service.h" header file
+ *
+ */
+int aul_open_service(const char *svcname, bundle *b, aul_service_res_fn cbfunc, void *data);
+
+/**
+ * @par Description:
+ * This API create service result bundle based on bundle received in reset event.
+ * @par Purpose:
+ * This API use to create result bundle to send it to caller.
+ * @par Typical use case:
+ * This API is for callee which provide application service.\n
+ * To send result to caller, You must create result bundle. \n
+ * Callee(application providing the service) can send result by using this API and aul_send_service_result.
+ *
+ * @param[in] inb bundle received in reset event
+ * @param[out] outb bundle to use for returning result
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - inb is not bundle created by aul_open_service
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * To create result bundle, You need received original bundle.
+ * The original bundle can get from app_reset handler.
+ * @post
+ * None
+ * @see
+ * aul_send_service_result
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int app_reset(bundle *b, void *data)
+ * {
+ * ad->recved_bundle = bundle_dup(b);
+ * }
+ *
+ * int click_ok()
+ * {
+ * bundle* res_bundle;
+ * aul_create_result_bundle(ad->recved_bundle,&res_bundle);
+ * bundle_add(res_bundle, "result", "1");
+ * aul_send_service_result(res_bundle);
+ * }
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_create_result_bundle(bundle *inb, bundle **outb);
+
+/**
+ * @par Description:
+ * This API send service result to caller with bundle
+ * @par Purpose:
+ * This API is used to send result bundle to caller.
+ * @par Typical use case:
+ * This API is for callee which provide application service.\n
+ * To send result to caller, You can use this API after creating result bundle. \n
+ * Callee(application to provide service) can send result by using this API and aul_create_result_bundle.
+ *
+ * @param[in] b Result data in bundle format
+ * @return 0 if success, negative value(<0) if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid result bundle
+ * @retval AUL_R_ECOMM - internal AUL IPC error
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * To send result bundle, You must create result bundle.
+ * see aul_create_result_bundle
+ * @post
+ * None
+ * @see
+ * aul_create_result_bundle
+ * @code
+ * #include <aul.h>
+ * #include <bundle.h>
+ *
+ * int app_reset(bundle *b, void *data)
+ * {
+ * ad->recved_bundle = bundle_dup(b);
+ * }
+ *
+ * int click_ok()
+ * {
+ * bundle* res_bundle;
+ * aul_create_result_bundle(ad->recved_bundle,&res_bundle);
+ * bundle_add(res_bundle, "result", "1");
+ * aul_send_service_result(res_bundle);
+ * }
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_send_service_result(bundle *b);
+
+/**
+ * @par Description:
+ * This API set the default application(appid) associated with service name
+ * @par Purpose:
+ * This API use to change default application associteted with service name
+ * In general, Setting Application needs this API.
+ * @par Typical use case:
+ * Default Application associated with service name can be changed by Setting Application
+ * So, Inhouse service application can be substituted by 3rd party service application
+ *
+ * @param[in] svcname service string like "create_contact"
+ * @param[in] defapp default application like "org.tizen.contact"
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(content)
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_get_defapp_for_service
+ * @code
+ * #include <aul.h>
+ * #include <aul_service.h>
+ *
+ * void set_camera_service_defapp()
+ * {
+ * aul_set_defapp_for_service(TAKE_PICTURE_SVC,"org.tizen.camera");
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_set_defapp_for_service(const char *svcname, const char *defapp);
+
+/**
+ * @par Description:
+ * This API get the application appid associated with given service name
+ * @par Purpose:
+ * This API use to get default application associteted with service name
+ * In general, Setting Application need this API.
+ * @par Typical use case:
+ * Setting Application show mapping of default application/ service
+ *
+ * @param[in] svcname service string like "create_contact"
+ * @param[out] defapp default application
+ * @param[in] len length of defapp
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_EINVAL - invalid argument(content)
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_set_defapp_for_service
+ * @code
+ * #include <aul.h>
+ * #include <aul_service.h>
+ *
+ * void get_camera_service_defapp()
+ * {
+ * char appname[255];
+ * aul_get_defapp_for_service(TAKE_PICTURE_SVC,appname,sizeof(appname));
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_get_defapp_for_service(const char *svcname, char *defapp, int len);
+
+/**
+ * @par Description:
+ * This API sets callback fuction that will be called when applications die.
+ * @par Purpose:
+ * This API's purpose is to listen the application dead event.
+ * In general, task manager Application need this API.
+ *
+ * @param[in] func callback function
+ * @param[in] data user data
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_listen_app_launch_signal
+ * @code
+ * #include <aul.h>
+ *
+ * int app_dead_handler(int pid, void *data)
+ * {
+ * printf("===> %s : %d\n", __FUNCTION__, pid);
+ * return 0;
+ * }
+ *
+ * void dead_listen()
+ * {
+ * aul_listen_app_dead_signal(app_dead_handler, NULL);
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
+
+/**
+ * @par Description:
+ * This API sets callback fuction that will be called when applications are launched.
+ * @par Purpose:
+ * This API's purpose is to listen the application launching event.
+ * In general, task manager Application need this API.
+ *
+ * @param[in] func callback function
+ * @param[in] data user data
+ * @return 0 if success, negative value if fail
+ * @retval AUL_R_OK - success
+ * @retval AUL_R_ERROR - general error
+ *
+ * @pre
+ * None
+ * @post
+ * None
+ * @see
+ * aul_listen_app_dead_signal
+ * @code
+ * #include <aul.h>
+ *
+ * int app_launch_handler(int pid, void *data)
+ * {
+ * printf("===> %s : %d\n", __FUNCTION__, pid);
+ * return 0;
+ * }
+ *
+ * void dead_listen()
+ * {
+ * aul_listen_app_launch_signal(app_launch_handler, NULL);
+ * }
+ *
+ * @endcode
+ * @remark
+ * None
+ *
+ */
+int aul_listen_app_launch_signal(int (*func) (int, void *), void *data);
+
+/** @} */
+
+
+
+#ifdef __cplusplus
+ }
+#endif
+
+
+#endif /* __AUL_H__ */
+
+/* vi: set ts=8 sts=8 sw=8: */
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef SLPAPI
+#define SLPAPI __attribute__ ((visibility("default")))
+#endif
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+/**
+ * @addtogroup aul_service
+ * @{
+ */
+
+/** alarm app_service, 1 svc */
+#define CREATE_ALARM_SVC "create_alarm"
+
+/** calendar app_service , 3 svc */
+#define OPEN_CALENDAR_SVC "open_calendar"
+#define CREATE_EVENT_SVC "create_event"
+#define VIEW_EVENT_SVC "view_event"
+
+/** camera app_service , 3 svc */
+#define TAKE_PICTURE_SVC "take_picture" /* have result*/
+#define RECORD_VIDEO_SVC "record_video" /* have result*/
+#define READ_BARCODE_SVC "read_barcode" /* have result*/
+
+/** contact app_service , 1 svs */
+#define SEARCH_CONTACT_SVC "search_contact"
+
+/** email app_service , 2 svc */
+#define CREATE_EMAIL_SVC "create_email"
+#define VIEW_EMAIL_SVC "view_email"
+
+/** file browser app_service, 1 svc */
+#define BROWSE_FILE_SVC "browse_file"
+
+/** memo app_service , 2 svc */
+#define CREATE_MEMO_SVC "create_memo"
+#define VIEW_MEMO_SVC "view_memo"
+
+/** message(sms,mms) app_service , 2 svc */
+#define CREATE_MESSAGE_SVC "create_message"
+#define VIEW_MESSAGE_SVC "view_message"
+
+/** search app_service, 1 svc */
+#define SEARCH_SVC "search"
+
+/** video call app_service, 1 svc */
+#define MAKE_VIDEOCALL_SVC "make_videocall"
+
+/** voice call app_service, 1 svc */
+#define MAKE_VOICECALL_SVC "make_voicecall"
+
+/** voice record app_service, 1 svc */
+#define RECORD_VOICE_SVC "record_voice" /* have result*/
+
+/** music player app_service, 1 svc */
+#define PLAY_MUSIC_SVC "play_music"
+
+/** web browser app_service, 1 svc */
+#define BROWSE_WEB_SVC "browse_web"
+
+/** facebook app_service, 1 svc */
+#define UPDATE_FACEBOOK_SVC "update_facebook"
+
+/** twitter app_service, 1 svc */
+#define UPDATE_TWITTER_SVC "update_twitter"
+
+/** ebook app_service, 1 svc */
+#define OPEN_EBOOK_SVC "open_ebook"
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __AUL_UTIL_H_
+#define __AUL_UTIL_H_
+
+#define AUL_UTIL_PID -2
+
+#define MAX_PACKAGE_STR_SIZE 512
+#define MAX_PACKAGE_APP_PATH_SIZE 512
+#define MAX_RUNNING_APP_INFO 512
+
+typedef struct _app_status_info_t{
+ char appid[MAX_PACKAGE_STR_SIZE];
+ char app_path[MAX_PACKAGE_APP_PATH_SIZE];
+ int status;
+ int pid;
+} app_status_info_t;
+
+struct amdmgr {
+ struct appinfomgr *af; /* appinfo manager */
+ struct cginfo *cg; /* cgroup infomation */
+};
+
+int _add_app_status_info_list(char *appid, int pid);
+int _update_app_status_info_list(int pid, int status);
+int _remove_app_status_info_list(int pid);
+
+#endif
+
+
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __APP_KEY_H_
+#define __APP_KEY_H_
+
+int app_key_event(bundle *kb);
+
+#endif
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __APP_LAUNCH_H_
+#define __APP_LAUNCH_H_
+
+#include <glib.h>
+
+int aul_initialize();
+int aul_register_init_callback(
+ int (*aul_handler)(aul_type type, bundle *, void *), void *data);
+int aul_is_initialized();
+int aul_sock_handler(int fd);
+int aul_make_bundle_from_argv(int argc, char **argv, bundle **kb);
+
+int app_start(bundle *kb);
+int app_send_cmd(int pid, int cmd, bundle *kb);
+int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb);
+
+int _app_start_res_prepare(bundle *kb);
+int app_result(int cmd, bundle *kb, int launched_pid);
+int aul_send_result(bundle *kb, int is_cancel);
+int aul_launch_app_with_result(const char *pkgname, bundle *kb,
+ void (*cbfunc) (bundle *, int, void *),
+ void *data);
+
+gboolean __aul_glib_handler(gpointer data);
+
+
+#endif
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <ail.h>
+#include <string.h>
+#include "simple_util.h"
+
+#define MAX_PATH_LEN 1024
+
+#define AUL_APP_INFO_FLD_PKG_NAME "package"
+#define AUL_APP_INFO_FLD_APP_PATH "exec"
+#define AUL_APP_INFO_FLD_APP_TYPE "x_slp_packagetype"
+#define AUL_APP_INFO_FLD_WIDTH "x_slp_baselayoutwidth"
+#define AUL_APP_INFO_FLD_HEIGHT "x_slp_baselayoutheight"
+#define AUL_APP_INFO_FLD_VERTICAL "x_slp_ishorizontalscale"
+#define AUL_APP_INFO_FLD_MULTIPLE "x_slp_multiple"
+#define AUL_APP_INFO_FLD_TASK_MANAGE "x_slp_taskmanage"
+#define AUL_APP_INFO_FLD_MIMETYPE "mimetype"
+#define AUL_APP_INFO_FLD_SERVICE "x_slp_service"
+
+#define AUL_RETRIEVE_PKG_NAME "package = '?'"
+#define AUL_RETRIEVE_APP_PATH "exec = '?'"
+#define AUL_RETRIEVE_MIMETYPE "mimetype like '?'"
+#define AUL_RETRIEVE_SERVICE "x_slp_service like '?'"
+
+typedef struct {
+ char *pkg_name; /* package */
+ char *app_path; /* exec */
+ char *original_app_path; /* exec */
+ char *pkg_type; /* x_slp_packagetype */
+ char *hwacc; /* hwacceleration */
+} app_info_from_db;
+
+static inline char *_get_pkgname(app_info_from_db *menu_info)
+{
+ return menu_info ? menu_info->pkg_name : NULL;
+}
+
+static inline char *_get_app_path(app_info_from_db *menu_info)
+{
+ int i = 0;
+ int path_len = -1;
+
+ if (!menu_info || menu_info->app_path == NULL)
+ return NULL;
+
+ while (menu_info->app_path[i] != 0) {
+ if (menu_info->app_path[i] == ' '
+ || menu_info->app_path[i] == '\t') {
+ path_len = i;
+ break;
+ }
+ i++;
+ }
+
+ if (path_len == 0) {
+ free(menu_info->app_path);
+ menu_info->app_path = NULL;
+ } else if (path_len > 0) {
+ char *tmp_app_path = malloc(sizeof(char) * (path_len + 1));
+ if(tmp_app_path == NULL)
+ return NULL;
+ snprintf(tmp_app_path, path_len + 1, "%s", menu_info->app_path);
+ free(menu_info->app_path);
+ menu_info->app_path = tmp_app_path;
+ }
+
+ return menu_info->app_path;
+}
+
+static inline char *_get_original_app_path(app_info_from_db *menu_info)
+{
+ return menu_info ? menu_info->original_app_path : NULL;
+}
+
+static inline void _free_app_info_from_db(app_info_from_db *menu_info)
+{
+ if (menu_info != NULL) {
+ if (menu_info->pkg_name != NULL)
+ free(menu_info->pkg_name);
+ if (menu_info->app_path != NULL)
+ free(menu_info->app_path);
+ if (menu_info->original_app_path != NULL)
+ free(menu_info->original_app_path);
+ if (menu_info->hwacc != NULL)
+ free(menu_info->hwacc);
+ free(menu_info);
+ }
+}
+
+static inline app_info_from_db *_get_app_info_from_db_by_pkgname(
+ const char *pkgname)
+{
+ app_info_from_db *menu_info;
+ ail_appinfo_h handle;
+ ail_error_e ret;
+ char *str = NULL;
+
+ menu_info = calloc(1, sizeof(app_info_from_db));
+ if (menu_info == NULL) {
+ return NULL;
+ }
+
+ ret = ail_get_appinfo(pkgname, &handle);
+ if (ret != AIL_ERROR_OK) {
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_PACKAGE_STR, &str);
+ if (str) {
+ menu_info->pkg_name = strdup(str);
+ str = NULL;
+ }
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &str);
+ if (str) {
+ menu_info->app_path = strdup(str);
+ str = NULL;
+ }
+
+ if (menu_info->app_path != NULL)
+ menu_info->original_app_path = strdup(menu_info->app_path);
+
+ ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGETYPE_STR, &str);
+ if (str) {
+ menu_info->pkg_type = strdup(str);
+ str = NULL;
+ }
+
+ ret = ail_destroy_appinfo(handle);
+ if (ret != AIL_ERROR_OK) {
+ _E("ail_destroy_appinfo failed");
+ }
+
+ if (!_get_app_path(menu_info)) {
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ return menu_info;
+}
+
+static inline ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
+{
+ app_info_from_db *menu_info = (app_info_from_db *)user_data;
+ char *package;
+ ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
+
+ if (!menu_info)
+ return ret;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+ if (package) {
+ menu_info->pkg_name = strdup(package);
+ ret = AIL_CB_RET_CANCEL;
+ }
+
+ return ret;
+}
+
+static inline app_info_from_db *_get_app_info_from_db_by_apppath(
+ const char *apppath)
+{
+ app_info_from_db *menu_info = NULL;
+ ail_filter_h filter;
+ ail_error_e ret;
+ int count;
+
+ if (apppath == NULL)
+ return NULL;
+
+ menu_info = calloc(1, sizeof(app_info_from_db));
+ if (menu_info == NULL)
+ return NULL;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK) {
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ ret = ail_filter_count_appinfo(filter, &count);
+ if (ret != AIL_ERROR_OK) {
+ ail_filter_destroy(filter);
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+ if (count < 1) {
+ ail_filter_destroy(filter);
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ ail_filter_list_appinfo_foreach(filter, __appinfo_func, (void *)menu_info);
+
+ ail_filter_destroy(filter);
+
+ menu_info->app_path = strdup(apppath);
+ menu_info->original_app_path = strdup(apppath);
+
+ return menu_info;
+
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __MIDA_H__
+#define __MIDA_H__
+
+#include <sqlite3.h>
+#include <time.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int mida_clear(void);
+int mida_delete_with_pkgname(const char *pkg_name);
+int mida_delete_with_mimetype(const char *mime_type);
+int mida_add_app(const char *mime_type, const char *pkg_name);
+char *mida_get_app(const char *mime_type);
+
+int svc_clear(void);
+int svc_delete_with_pkgname(const char *pkg_name);
+int svc_delete_with_svcname(const char *svc_name);
+int svc_add_app(const char *svc_name, const char *pkg_name);
+char *svc_get_app(const char *svc_name);
+
+int is_supported_svc(const char *svc_name);
+#ifdef __cplusplus
+}
+#endif
+#endif /*__MIDA_H__ */
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef _MIREGEX_H_
+#define _MIREGEX_H_
+
+#include <regex.h>
+
+typedef struct _regex_tbl {
+ char *mimetype;
+ char *regex;
+ char *desc;
+ regex_t regex_preg;
+ struct _regex_tbl *next;
+} regex_tbl;
+
+regex_tbl *miregex_get_regex_table();
+
+#endif
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __PERF_H__
+#define __PERF_H__
+
+#ifdef PERF_ACTIVATE
+
+#include <sys/time.h>
+static struct timeval __g_base_time = {
+ .tv_sec = 0,
+ .tv_usec = 0
+};
+
+#define INIT_PERF(kb)\
+do {\
+ const char *tmp;\
+ struct timeval tv;\
+ tmp = bundle_get_val(kb, AUL_K_STARTTIME);\
+ if (tmp != NULL)\
+ sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);\
+ else\
+ gettimeofday(&tv, NULL);\
+ __g_base_time.tv_sec = tv.tv_sec;\
+ __g_base_time.tv_usec = tv.tv_usec;\
+} while (0);
+
+#define PERF(fmt, arg...)\
+do {\
+ struct timeval cur;\
+ struct timeval res;\
+ gettimeofday(&cur, NULL);\
+ if (__g_base_time.tv_sec != 0) {\
+ timersub(&cur, &__g_base_time, &res);\
+ printf("%c[1;31m[%s,%d] %ld sec %ld msec "fmt" %c[0m\n",\
+ 27, __FUNCTION__, __LINE__, \
+ res.tv_sec, res.tv_usec/1000, ##arg, 27);\
+ } \
+} while (0);
+
+#else
+
+#define INIT_PERF(kb)
+#define PERF(fmt, arg...)
+
+#endif
+
+#endif
+
--- /dev/null
+# Doxyfile 1.5.2
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+# TAG = value [value, ...]
+# For lists items can also be appended using:
+# TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+DOXYFILE_ENCODING = UTF-8
+PROJECT_NAME = SLP-Developer Library
+PROJECT_NUMBER =
+OUTPUT_DIRECTORY = ./doxygen_output
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF = NO
+ALWAYS_DETAILED_SEC = YES
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = YES
+JAVADOC_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = YES
+INHERIT_DOCS = YES
+SEPARATE_MEMBER_PAGES = YES
+TAB_SIZE = 8
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+BUILTIN_STL_SUPPORT = NO
+CPP_CLI_SUPPORT = NO
+DISTRIBUTE_GROUP_DOC = NO
+SUBGROUPING = YES
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = YES
+EXTRACT_STATIC = YES
+EXTRACT_LOCAL_CLASSES = NO
+EXTRACT_LOCAL_METHODS = YES
+HIDE_UNDOC_MEMBERS = YES
+HIDE_UNDOC_CLASSES = YES
+HIDE_FRIEND_COMPOUNDS = YES
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = YES
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = YES
+SORT_BY_SCOPE_NAME = YES
+SORT_GROUP_NAMES = YES
+GENERATE_TODOLIST = NO
+USE_INLINE_TREES = NO
+SHOW_NAMESPACES = NO
+HTML DYNAMIC SECTIONS = YES
+GENERATE_TESTLIST = NO
+GENERATE_BUGLIST = NO
+GENERATE_DEPRECATEDLIST= NO
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = NO
+FILE_VERSION_FILTER =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT = ..
+
+# This tag can be used to specify the character encoding of the source files that
+# doxygen parses. Internally doxygen uses the UTF-8 encoding, which is also the default
+# input encoding. Doxygen uses libiconv (or the iconv built into libc) for the transcoding.
+# See http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+INPUT_ENCODING = UTF-8
+FILE_PATTERNS = *.h \
+ *.doxy
+RECURSIVE = YES
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS = */test/* \
+ */debian/* \
+ */lost+found/* \
+ */i386/* \
+ */arm/* \
+ */simulator/* \
+ *test* \
+ */voda3rd/*
+EXCLUDE_SYMBOLS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH = ../image
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES (the default)
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = YES
+
+# If the REFERENCES_RELATION tag is set to YES (the default)
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION = YES
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code. Otherwise they will link to the documentstion.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 10
+IGNORE_PREFIX =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET =./slp_doxy.css
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compressed HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP = YES
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND = NO
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE = 4
+
+# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be
+# generated containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+,
+# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are
+# probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW = YES
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH = 190
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS = NO
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX = NO
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX = YES
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader. This is useful
+# if you want to understand what is going on. On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED =
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS = NO
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see http://www.mcternan.me.uk/mscgen/) to
+# produce the chart and insert it in the documentation. The MSCGEN_PATH tag allows you to
+# specify the directory where the mscgen tool resides. If left empty the tool is assumed to
+# be found in the default search path.
+
+MSCGEN_PATH =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT = NO
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH = NO
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH = NO
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS = NO
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH = NO
+
+# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will
+# generate a call dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable call graphs for selected
+# functions only using the \callgraph command.
+
+CALL_GRAPH = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will
+# generate a caller dependency graph for every global function or class method.
+# Note that enabling this option will significantly increase the time of a run.
+# So in most cases it will be better to enable caller graphs for selected
+# functions only using the \callergraph command.
+
+CALLER_GRAPH = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY = NO
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH = NO
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT = jpg
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS =
+
+# The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen will always
+# show the root nodes and its direct children regardless of this setting.
+
+DOT_GRAPH_MAX_NODES = 50
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, which results in a white background.
+# Warning: Depending on the platform used, enabling this option may lead to
+# badly anti-aliased labels on the edges of a graph (i.e. they become hard to
+# read).
+
+DOT_TRANSPARENT = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND = NO
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP = NO
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+
+# The SEARCHENGINE tag specifies whether or not a search engine should be
+# used. If set to NO the values of all tags below this one will be ignored.
+
+SEARCHENGINE = YES
--- /dev/null
+#!/bin/bash
+
+# Create doxygen from debian package server
+# By Jungbae Lee (yi_jungbae@samsung.com)
+
+cd `dirname $0`
+CWD=`pwd`
+
+# Use doxygen 1.7.0
+export PATH=/usr/local/bin:${HOME}/mytools/bin:${PATH}
+export LD_LIBRARY_PATH=${HOME}/mytools/lib:${LD_LIBRARY_PATH}
+
+
+### Configuration
+SBOX=/scratchbox/users/$USER/home/$USER
+DOXYGEN_OUTPUT_DIR=$CWD/doxygen_output
+DOXYGEN=./tool/bin/doxygen
+DOXY_CONF=doxygen.conf
+IMAGE_DIR=../../image #need to change
+#IMAGE_DIR=[fill your image path]
+
+
+
+####doxygen configuration :: output Directory
+mkdir $DOXYGEN_OUTPUT_DIR
+
+echo "Doxygen running..."
+if [ ! -e $CWD/doxygen_output ]; then
+ mkdir $CWD/doxygen_output
+fi
+# Run doxygen
+$DOXYGEN $DOXY_CONF 2>&1
+
+#image copy
+cp $CWD/$IMAGE_DIR/* $DOXYGEN_OUTPUT_DIR/html/
+
+echo "Finished!"
+exit;
+
--- /dev/null
+/* The standard CSS for doxygen */
+
+body, table, div, p, dl {
+ font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif;
+ font-size: 12px;
+}
+
+/* @group Heading Levels */
+
+h1 {
+ font-size: 18pt;
+ color: #3366ED;
+}
+
+h1.pg {
+ font-size: 18pt;
+ color: #336666;
+ margin-right:-0.6pt;
+ margin-left:0cm;
+ padding-top:0cm;
+ padding-right:0cm;
+ padding-bottom:1pt;
+ padding-left:0cm;
+ border-bottom-width:1.5pt;
+ border-bottom-color:#336666;
+ border-top-style:none;
+ border-right-style:none;
+ border-bottom-style:solid;
+ border-left-style:none;
+}
+
+h2 {
+ font-size: 14pt;
+ color: #336666;
+}
+h2.pg {
+ font-size: 14pt;
+ color: #336666;
+ margin-right:-0.1pt;
+ margin-left:0cm;
+ padding-top:0cm;
+ padding-right:0cm;
+ padding-bottom:1pt;
+ padding-left:0cm;
+ border-bottom-width:1.2pt;
+ border-bottom-color:#336666;
+ border-top-style:none;
+ border-right-style:none;
+ border-bottom-style:solid;
+ border-left-style:none;
+}
+
+
+h3 {
+ font-size: 12pt;
+ color: #336666;
+}
+h3.pg {
+ font-size: 12pt;
+ color: #336666;
+}
+
+
+
+dt {
+ font-weight: bold;
+}
+
+div.multicol {
+ -moz-column-gap: 1em;
+ -webkit-column-gap: 1em;
+ -moz-column-count: 3;
+ -webkit-column-count: 3;
+}
+
+p.startli, p.startdd, p.starttd {
+ margin-top: 2px;
+}
+
+p.endli {
+ margin-bottom: 0px;
+}
+
+p.enddd {
+ margin-bottom: 4px;
+}
+
+p.endtd {
+ margin-bottom: 2px;
+}
+
+/* @end */
+
+caption {
+ font-weight: bold;
+}
+
+span.legend {
+ font-size: 70%;
+ text-align: center;
+}
+
+h3.version {
+ font-size: 90%;
+ text-align: center;
+}
+
+div.qindex, div.navtab{
+ background-color: #EBEFF6;
+ border: 1px solid #A3B4D7;
+ text-align: center;
+ margin: 2px;
+ padding: 2px;
+}
+
+div.qindex, div.navpath {
+ width: 100%;
+ line-height: 140%;
+}
+
+div.navtab {
+ margin-right: 15px;
+}
+
+/* @group Link Styling */
+
+a {
+ color: #3D578C;
+ font-weight: normal;
+ text-decoration: none;
+}
+
+.contents a:visited {
+ color: #4665A2;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+a.qindex {
+ font-weight: bold;
+}
+
+a.qindexHL {
+ font-weight: bold;
+ background-color: #9CAFD4;
+ color: #ffffff;
+ border: 1px double #869DCA;
+}
+
+.contents a.qindexHL:visited {
+ color: #ffffff;
+}
+
+a.el {
+ font-weight: bold;
+}
+
+a.elRef {
+}
+
+a.code {
+ color: #4665A2;
+}
+
+a.codeRef {
+ color: #4665A2;
+}
+
+/* @end */
+
+dl.el {
+ margin-left: -1cm;
+}
+
+.fragment {
+ font-family: monospace, fixed;
+ font-size: 105%;
+}
+
+pre.fragment {
+ border: 1px solid #C4CFE5;
+ background-color: #FBFCFD;
+ padding: 4px 6px;
+ margin: 4px 8px 4px 2px;
+ overflow: auto;
+ word-wrap: break-word;
+ font-size: 9pt;
+ line-height: 125%;
+}
+
+div.ah {
+ background-color: black;
+ font-weight: bold;
+ color: #ffffff;
+ margin-bottom: 3px;
+ margin-top: 3px
+ padding: .2em;
+ border: solid thin #333;
+ border-radius: .5em;
+ -webkit-border-radius: .5em;
+ -moz-border-radius: .5em;
+ -webkit-box-shadow: 2px 2px 3px #999;
+ -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444));
+ background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000);
+}
+
+div.groupHeader {
+ margin-left: 16px;
+ margin-top: 12px;
+ margin-bottom: 6px;
+ font-weight: bold;
+}
+
+div.groupText {
+ margin-left: 16px;
+ font-style: italic;
+}
+
+body {
+ background: white;
+ color: black;
+ margin: 0;
+}
+
+div.contents {
+ margin-top: 10px;
+ margin-left: 10px;
+ margin-right: 10px;
+}
+
+td.indexkey {
+ background-color: #EBEFF6;
+ font-weight: bold;
+ border: 1px solid #C4CFE5;
+ margin: 2px 0px 2px 0;
+ padding: 2px 10px;
+}
+
+td.indexvalue {
+ background-color: #EBEFF6;
+ border: 1px solid #C4CFE5;
+ padding: 2px 10px;
+ margin: 2px 0px;
+}
+
+tr.memlist {
+ background-color: #EEF1F7;
+}
+
+p.formulaDsp {
+ text-align: center;
+}
+
+img.formulaDsp {
+
+}
+
+img.formulaInl {
+ vertical-align: middle;
+}
+
+div.center {
+ text-align: center;
+ margin-top: 0px;
+ margin-bottom: 0px;
+ padding: 0px;
+}
+
+div.center img {
+ border: 0px;
+}
+
+address.footer {
+ text-align: right;
+ padding-right: 12px;
+}
+
+img.footer {
+ border: 0px;
+ vertical-align: middle;
+}
+
+/* @group Code Colorization */
+
+span.keyword {
+ color: #008000
+}
+
+span.keywordtype {
+ color: #604020
+}
+
+span.keywordflow {
+ color: #e08000
+}
+
+span.comment {
+ color: #800000
+}
+
+span.preprocessor {
+ color: #806020
+}
+
+span.stringliteral {
+ color: #002080
+}
+
+span.charliteral {
+ color: #008080
+}
+
+span.vhdldigit {
+ color: #ff00ff
+}
+
+span.vhdlchar {
+ color: #000000
+}
+
+span.vhdlkeyword {
+ color: #700070
+}
+
+span.vhdllogic {
+ color: #ff0000
+}
+
+/* @end */
+
+/*
+.search {
+ color: #003399;
+ font-weight: bold;
+}
+
+form.search {
+ margin-bottom: 0px;
+ margin-top: 0px;
+}
+
+input.search {
+ font-size: 75%;
+ color: #000080;
+ font-weight: normal;
+ background-color: #e8eef2;
+}
+*/
+
+td.tiny {
+ font-size: 75%;
+}
+
+.dirtab {
+ padding: 4px;
+ border-collapse: collapse;
+ border: 1px solid #A3B4D7;
+}
+
+th.dirtab {
+ background: #EBEFF6;
+ font-weight: bold;
+}
+
+hr {
+ height: 0px;
+ border: none;
+ border-top: 1px solid #4A6AAA;
+}
+
+hr.footer {
+ height: 1px;
+}
+
+/* @group Member Descriptions */
+
+table.memberdecls {
+ border-spacing: 0px;
+ padding: 0px;
+}
+
+.mdescLeft, .mdescRight,
+.memItemLeft, .memItemRight,
+.memTemplItemLeft, .memTemplItemRight, .memTemplParams {
+ background-color: #F9FAFC;
+ border: none;
+ margin: 4px;
+ padding: 1px 0 0 8px;
+}
+
+.mdescLeft, .mdescRight {
+ padding: 0px 8px 4px 8px;
+ color: #555;
+}
+
+.memItemLeft, .memItemRight, .memTemplParams {
+ border-top: 1px solid #C4CFE5;
+}
+
+.memItemLeft, .memTemplItemLeft {
+ white-space: nowrap;
+}
+
+.memTemplParams {
+ color: #4665A2;
+ white-space: nowrap;
+}
+
+/* @end */
+
+/* @group Member Details */
+
+/* Styles for detailed member documentation */
+
+.memtemplate {
+ font-size: 80%;
+ color: #4665A2;
+ font-weight: normal;
+ margin-left: 3px;
+}
+
+.memnav {
+ background-color: #EBEFF6;
+ border: 1px solid #A3B4D7;
+ text-align: center;
+ margin: 2px;
+ margin-right: 15px;
+ padding: 2px;
+}
+
+.memitem {
+ padding: 0;
+ margin-bottom: 10px;
+}
+
+.memname {
+ white-space: nowrap;
+ font-weight: bold;
+ margin-left: 6px;
+}
+
+.memproto {
+ border-top: 1px solid #A8B8D9;
+ border-left: 1px solid #A8B8D9;
+ border-right: 1px solid #A8B8D9;
+ padding: 6px 0px 6px 0px;
+ color: #253555;
+ font-weight: bold;
+ text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9);
+ /* firefox specific markup */
+ -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px;
+ -moz-border-radius-topright: 8px;
+ -moz-border-radius-topleft: 8px;
+ /* webkit specific markup */
+ -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
+ -webkit-border-top-right-radius: 8px;
+ -webkit-border-top-left-radius: 8px;
+ background-image:url('nav_f.png');
+ background-repeat:repeat-x;
+ background-color: #E2E8F2;
+
+}
+
+.memdoc {
+ border-bottom: 1px solid #A8B8D9;
+ border-left: 1px solid #A8B8D9;
+ border-right: 1px solid #A8B8D9;
+ padding: 2px 5px;
+ background-color: #FBFCFD;
+ border-top-width: 0;
+ /* firefox specific markup */
+ -moz-border-radius-bottomleft: 8px;
+ -moz-border-radius-bottomright: 8px;
+ -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px;
+ background-image: -moz-linear-gradient(center top, #FFFFFF 0%, #FFFFFF 60%, #F8 95%, #F0);
+ /* webkit specific markup */
+ -webkit-border-bottom-left-radius: 8px;
+ -webkit-border-bottom-right-radius: 8px;
+ -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
+ background-image: -webkit-gradient(linear,center top,center bottom,from(#FFFFFF), color-stop(0.6,#FFFFFF), color-stop(0.60,#FF), color-stop(0.95,#F8), to(#F0));
+}
+
+.paramkey {
+ text-align: right;
+}
+
+.paramtype {
+ white-space: nowrap;
+}
+
+.paramname {
+ color: #602020;
+ white-space: nowrap;
+}
+.paramname em {
+ font-style: normal;
+}
+
+/* @end */
+
+/* @group Directory (tree) */
+
+/* for the tree view */
+
+.ftvtree {
+ font-family: sans-serif;
+ margin: 0px;
+}
+
+/* these are for tree view when used as main index */
+
+.directory {
+ font-size: 9pt;
+ font-weight: bold;
+ margin: 5px;
+}
+
+.directory h3 {
+ margin: 0px;
+ margin-top: 1em;
+ font-size: 11pt;
+}
+
+/*
+The following two styles can be used to replace the root node title
+with an image of your choice. Simply uncomment the next two styles,
+specify the name of your image and be sure to set 'height' to the
+proper pixel height of your image.
+*/
+
+/*
+.directory h3.swap {
+ height: 61px;
+ background-repeat: no-repeat;
+ background-image: url("yourimage.gif");
+}
+.directory h3.swap span {
+ display: none;
+}
+*/
+
+.directory > h3 {
+ margin-top: 0;
+}
+
+.directory p {
+ margin: 0px;
+ white-space: nowrap;
+}
+
+.directory div {
+ display: none;
+ margin: 0px;
+}
+
+.directory img {
+ vertical-align: -30%;
+}
+
+/* these are for tree view when not used as main index */
+
+.directory-alt {
+ font-size: 100%;
+ font-weight: bold;
+}
+
+.directory-alt h3 {
+ margin: 0px;
+ margin-top: 1em;
+ font-size: 11pt;
+}
+
+.directory-alt > h3 {
+ margin-top: 0;
+}
+
+.directory-alt p {
+ margin: 0px;
+ white-space: nowrap;
+}
+
+.directory-alt div {
+ display: none;
+ margin: 0px;
+}
+
+.directory-alt img {
+ vertical-align: -30%;
+}
+
+/* @end */
+
+div.dynheader {
+ margin-top: 8px;
+}
+
+address {
+ font-style: normal;
+ color: #2A3D61;
+}
+
+table.doxtable {
+ border-collapse:collapse;
+}
+
+table.doxtable td, table.doxtable th {
+ border: 1px solid #2D4068;
+ padding: 3px 7px 2px;
+}
+
+table.doxtable th {
+ background-color: #374F7F;
+ color: #FFFFFF;
+ font-size: 110%;
+ padding-bottom: 4px;
+ padding-top: 5px;
+ text-align:left;
+}
+
+.tabsearch {
+ top: 0px;
+ left: 10px;
+ height: 36px;
+ background-image: url('tab_b.png');
+ z-index: 101;
+ overflow: hidden;
+ font-size: 13px;
+}
+
+.navpath ul
+{
+ font-size: 11px;
+ background-image:url('tab_b.png');
+ background-repeat:repeat-x;
+ height:30px;
+ line-height:30px;
+ color:#8AA0CC;
+ border:solid 1px #C2CDE4;
+ overflow:hidden;
+ margin:0px;
+ padding:0px;
+}
+
+.navpath li
+{
+ list-style-type:none;
+ float:left;
+ padding-left:10px;
+ padding-right: 15px;
+ background-image:url('bc_s.png');
+ background-repeat:no-repeat;
+ background-position:right;
+ color:#364D7C;
+}
+
+.navpath a
+{
+ height:32px;
+ display:block;
+ text-decoration: none;
+ outline: none;
+}
+
+.navpath a:hover
+{
+ color:#6884BD;
+}
+
+div.summary
+{
+ float: right;
+ font-size: 8pt;
+ padding-right: 5px;
+ width: 50%;
+ text-align: right;
+}
+
+div.summary a
+{
+ white-space: nowrap;
+}
+
+div.header
+{
+ background-image:url('nav_h.png');
+ background-repeat:repeat-x;
+ background-color: #F9FAFC;
+ margin: 0px;
+ border-bottom: 1px solid #C4CFE5;
+}
+
+div.headertitle
+{
+ padding: 5px 5px 5px 10px;
+}
+
--- /dev/null
+.TH DOXYGEN "1" "July 2010" "doxygen 1.7.0" "User Commands"
+.SH NAME
+doxygen \- documentation system for various programming languages
+.SH DESCRIPTION
+Doxygen is a documentation system for C++, C, Java, Objective-C, IDL
+(Corba and Microsoft flavors) and to some extent PHP, C#, and D.
+.PP
+You can use doxygen in a number of ways:
+.TP
+1) Use doxygen to generate a template configuration file:
+.IP
+doxygen [-s] \fB\-g\fR [configName]
+.IP
+If - is used for configName doxygen will write to standard output.
+.TP
+2) Use doxygen to update an old configuration file:
+.IP
+doxygen [-s] \fB\-u\fR [configName]
+.TP
+3) Use doxygen to generate documentation using an existing configuration file:
+.IP
+doxygen [configName]
+.IP
+If - is used for configName doxygen will read from standard input.
+.TP
+4) Use doxygen to generate a template style sheet file for RTF, HTML or Latex.
+.TP
+RTF:
+doxygen \fB\-w\fR rtf styleSheetFile
+.TP
+HTML:
+doxygen \fB\-w\fR html headerFile footerFile styleSheetFile [configFile]
+.TP
+LaTeX: doxygen \fB\-w\fR latex headerFile styleSheetFile [configFile]
+.TP
+5) Use doxygen to generate an rtf extensions file
+.TP
+RTF:
+doxygen \fB\-e\fR rtf extensionsFile
+.PP
+If \fB\-s\fR is specified the comments in the config file will be omitted.
+If configName is omitted `Doxyfile' will be used as a default.
+.SH AUTHOR
+Doxygen version 1.7.0, Copyright Dimitri van Heesch 1997-2007
+.SH SEE ALSO
+doxytag(1), doxywizard(1).
--- /dev/null
+.TH DOXYTAG "1" "July 2010" "doxytag 1.7.0" "User Commands"
+.SH NAME
+doxytag \- generates a tag file and/or a search index for a set of HTML files
+.SH SYNOPSIS
+.B doxytag
+[\fI-t tag_file\fR] [\fI-s index_file\fR] [ \fIhtml_file \fR[\fIhtml_file\fR...] ]
+.SH DESCRIPTION
+Generates a tag file and/or a search index for a set of HTML files. Use
+doxysearch as a CGI program to search the tag file generated by doxytag.
+.SH OPTIONS
+.TP
+\fB\-t\fR <tag_file>
+Generate tag file <tag_file>.
+.TP
+\fB\-s\fR <index_file>
+Generate search index <index_file>.
+.PP
+If no HTML files are given all files in the current dir that
+have a .html extension are parsed.
+.SH SEE ALSO
+doxygen(1), doxywizard(1).
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __SIMPLE_UTIL__
+#define __SIMPLE_UTIL__
+
+#include <unistd.h>
+#include <ctype.h>
+#include <dlog.h>
+
+#ifdef LAUNCHPAD_LOG
+#undef LOG_TAG
+#define LOG_TAG "AUL_PAD"
+#else
+#undef LOG_TAG
+#define LOG_TAG "AUL"
+#endif
+#ifdef AMD_LOG
+#undef LOG_TAG
+#define LOG_TAG "AUL_AMD"
+#endif
+
+
+#define MAX_LOCAL_BUFSZ 128
+#define MAX_PID_STR_BUFSZ 20
+
+#define _E(fmt, arg...) LOGE(fmt, ##arg)
+#define _D(fmt, arg...) LOGD(fmt, ##arg)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+ if (expr) { \
+ _E(fmt, ##arg); \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+ if (expr) { \
+ _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+ return (val); \
+ } \
+} while (0)
+
+int __proc_iter_cmdline(int (*iterfunc)
+ (const char *dname, const char *cmdline, void *priv),
+ void *priv);
+int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv),
+ void *priv);
+char *__proc_get_cmdline_bypid(int pid);
+
+static inline const char *FILENAME(const char *filename)
+{
+ const char *p;
+ const char *r;
+
+ if (!filename)
+ return NULL;
+
+ r = p = filename;
+ while (*p) {
+ if (*p == '/')
+ r = p + 1;
+ p++;
+ }
+
+ return r;
+}
+
+#endif
--- /dev/null
+#!/bin/sh
+mkdir /tmp/alaunch
+chmod 1777 /tmp/alaunch
+
+
+/usr/bin/amd &
+/usr/bin/launchpad_preloading_preinitializing_daemon " " &
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifdef DAC_ACTIVATE
+
+#include <privilege-control.h>
+
+#define INHOUSE_UID 5000
+static inline int __set_access(const char* pkg_name, const char* pkg_type, const char* app_path)
+{
+ return set_app_privilege(pkg_name, pkg_type, app_path);
+}
+
+#else
+
+static inline int __set_access(const char* pkg_name, const char* pkg_type, const char* app_path)
+{
+ return 0;
+}
+
+#endif
+
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#define LAUNCHPAD_LOG
+#define DAC_ACTIVATE
+#define PRELOAD_ACTIVATE
+#define PREEXEC_ACTIVATE
+/*#define GL_ACTIVATE*/
+/*#define HEAPDGB_ACTIVATE*/
+/*#define PERF_ACTIVATE*/
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifdef GL_ACTIVATE
+
+#define USE_ENGINE(engine) setenv("ELM_ENGINE", engine, 1);
+
+#else
+
+#define USE_ENGINE(engine)
+
+#endif
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <malloc.h>
+#include <stdio.h>
+#include <signal.h>
+
+#ifdef HEAPDGB_ACTIVATE
+
+#define HOOK_RESET() \
+do {\
+ __malloc_hook = old_malloc_hook; \
+ __free_hook = old_free_hook; \
+} while (0);
+
+#define HOOK_SET() \
+do {\
+ __malloc_hook = my_malloc; \
+ __free_hook = my_free; \
+} while (0);
+
+static void *(*old_malloc_hook) (size_t size, const void *caller);
+static void *(*old_realloc_hook) (void *ptr, size_t size, const void *caller);
+static void (*old_free_hook) (void *ptr, const void *caller);
+
+static void *my_malloc(size_t size, const void *caller);
+static void *my_realloc(void *ptr, size_t size, const void *caller);
+static void my_free(void *ptr, const void *caller);
+
+static void my_free(void *ptr, const void *caller)
+{
+ void *callstack_addrs[20];
+ char **callstack_strings;
+ int i;
+
+ HOOK_RESET();
+
+ printf("%c[1;31m[FREE] %x %x", 27, ptr, caller);
+ printf("%c[0m\n", 27);
+ free(ptr);
+
+ HOOK_SET();
+
+}
+
+static void *my_malloc(size_t size, const void *caller)
+{
+ void *ptr;
+
+ HOOK_RESET();
+
+ ptr = malloc(size);
+ printf("%c[1;31m[MALLOC] %x %x", 27, ptr, caller);
+ printf("%c[0m\n", 27);
+
+ HOOK_SET();
+
+ return ptr;
+}
+
+static void malloc_init(void)
+{
+ old_malloc_hook = __malloc_hook;
+ old_free_hook = __free_hook;
+
+ HOOK_SET();
+}
+
+__attribute__ ((visibility("default")))
+void (*__malloc_initialize_hook) (void) = malloc_init;
+
+#else
+
+#endif
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+/*
+ * simple AUL daemon - launchpad
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <X11/Xlib.h>
+#include <sys/types.h>
+#include <signal.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <poll.h>
+#include <sys/prctl.h>
+#include <malloc.h>
+
+#include "app_sock.h"
+#include "aul.h"
+
+#include "config.h"
+
+#include "menu_db_util.h"
+#include "simple_util.h"
+#include "access_control.h"
+#include "preload.h"
+#include "preexec.h"
+#include "perf.h"
+#include "sigchild.h"
+#include "aul_util.h"
+
+#include "heap_dbg.h"
+
+#include "util_x.h"
+
+#include "gl.h"
+
+#include <app-checker.h>
+#include <sqlite3.h>
+
+#define _static_ static inline
+#define POLLFD_MAX 1
+#define SQLITE_FLUSH_MAX (1048576) /* (1024*1024) */
+#define AUL_POLL_CNT 15
+#define AUL_PR_NAME 16
+#define PATH_APP_ROOT "/opt/usr/apps"
+#define PATH_DATA "/data"
+#define SDK_CODE_COVERAGE "CODE_COVERAGE"
+#define SDK_DYNAMIC_ANALYSIS "DYNAMIC_ANALYSIS"
+#define PATH_DA_SO "/home/developer/sdk_tools/da/da_probe.so"
+
+
+static char *launchpad_cmdline;
+static int initialized = 0;
+
+
+_static_ void __set_oom();
+_static_ void __set_env(app_info_from_db * menu_info, bundle * kb);
+_static_ int __prepare_exec(const char *pkg_name,
+ const char *app_path, app_info_from_db * menu_info,
+ bundle * kb);
+_static_ int __fake_launch_app(int cmd, int pid, bundle * kb);
+_static_ char **__create_argc_argv(bundle * kb, int *margc);
+_static_ int __normal_fork_exec(int argc, char **argv);
+_static_ void __real_launch(const char *app_path, bundle * kb);
+static inline int __parser(const char *arg, char *out, int out_size);
+_static_ void __modify_bundle(bundle * kb, int caller_pid,
+ app_info_from_db * menu_info, int cmd);
+_static_ int __child_raise_win_by_x(int pid, void *priv);
+_static_ int __raise_win_by_x(int pid);
+_static_ int __send_to_sigkill(int pid);
+_static_ int __term_app(int pid);
+_static_ int __resume_app(int pid);
+_static_ void __real_send(int clifd, int ret);
+_static_ void __send_result_to_caller(int clifd, int ret);
+_static_ void __launchpad_main_loop(int main_fd);
+_static_ int __launchpad_pre_init(int argc, char **argv);
+_static_ int __launchpad_post_init();
+
+extern ail_error_e ail_db_close(void);
+
+
+
+_static_ void __set_oom()
+{
+ char buf[MAX_LOCAL_BUFSZ];
+ FILE *fp;
+
+ /* we should reset oomadj value as default because child
+ inherits from parent oom_adj*/
+ snprintf(buf, MAX_LOCAL_BUFSZ, "/proc/%d/oom_adj", getpid());
+ fp = fopen(buf, "w");
+ if (fp == NULL)
+ return;
+ fprintf(fp, "%d", -16);
+ fclose(fp);
+}
+
+_static_ void __set_sdk_env(app_info_from_db* menu_info, char* str) {
+ char buf[MAX_LOCAL_BUFSZ];
+ int ret;
+
+ _D("key : %s / value : %s", AUL_K_SDK, str);
+ /* http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html*/
+ /* GCOV_PREFIX contains the prefix to add to the absolute paths in the object file. */
+ /* Prefix can be absolute, or relative. The default is no prefix. */
+ /* GCOV_PREFIX_STRIP indicates the how many initial directory names */
+ /* to stripoff the hardwired absolute paths. Default value is 0. */
+ if (strncmp(str, SDK_CODE_COVERAGE, strlen(str)) == 0) {
+ snprintf(buf, MAX_LOCAL_BUFSZ, PATH_APP_ROOT"/%s"PATH_DATA, _get_pkgname(menu_info));
+ ret = setenv("GCOV_PREFIX", buf, 1);
+ _D("GCOV_PREFIX : %d", ret);
+ ret = setenv("GCOV_PREFIX_STRIP", "4096", 1);
+ _D("GCOV_PREFIX_STRIP : %d", ret);
+ } else if (strncmp(str, SDK_DYNAMIC_ANALYSIS, strlen(str)) == 0) {
+ ret = setenv("LD_PRELOAD", PATH_DA_SO, 1);
+ _D("LD_PRELOAD : %d", ret);
+ }
+}
+
+
+_static_ void __set_env(app_info_from_db * menu_info, bundle * kb)
+{
+ const char *str;
+ const char **str_array;
+ int len;
+ int i;
+
+ setenv("PKG_NAME", _get_pkgname(menu_info), 1);
+
+ USE_ENGINE("gl")
+
+ str = bundle_get_val(kb, AUL_K_STARTTIME);
+ if (str != NULL)
+ setenv("APP_START_TIME", str, 1);
+
+ if(bundle_get_type(kb, AUL_K_SDK) & BUNDLE_TYPE_ARRAY) {
+ str_array = bundle_get_str_array(kb, AUL_K_SDK, &len);
+ if(str_array != NULL) {
+ for (i = 0; i < len; i++) {
+ _D("index : [%d]", i);
+ __set_sdk_env(menu_info, (char *)str_array[i]);
+ }
+ }
+ } else {
+ str = bundle_get_val(kb, AUL_K_SDK);
+ if(str != NULL) {
+ __set_sdk_env(menu_info, (char *)str);
+ }
+ }
+ if (menu_info->hwacc != NULL)
+ setenv("HWACC", menu_info->hwacc, 1);
+}
+
+_static_ int __prepare_exec(const char *pkg_name,
+ const char *app_path, app_info_from_db * menu_info,
+ bundle * kb)
+{
+ char *file_name;
+ char process_name[AUL_PR_NAME];
+
+ /* Set new session ID & new process group ID*/
+ /* In linux, child can set new session ID without check permission */
+ /* TODO : should be add to check permission in the kernel*/
+ setsid();
+
+ __preexec_run(menu_info->pkg_type, pkg_name, app_path);
+
+ /* SET OOM*/
+ __set_oom();
+
+ /* SET PRIVILEGES*/
+ if (__set_access(pkg_name, menu_info->pkg_type, app_path) < 0) {
+ _D("fail to set privileges - check your package's credential\n");
+ return -1;
+ }
+ /* SET DUMPABLE - for coredump*/
+ prctl(PR_SET_DUMPABLE, 1);
+
+ /* SET PROCESS NAME*/
+ if (app_path == NULL) {
+ _D("app_path should not be NULL - check menu db");
+ return -1;
+ }
+ file_name = strrchr(app_path, '/') + 1;
+ if (file_name == NULL) {
+ _D("can't locate file name to execute");
+ return -1;
+ }
+ memset(process_name, '\0', AUL_PR_NAME);
+ snprintf(process_name, AUL_PR_NAME, "%s", file_name);
+ prctl(PR_SET_NAME, process_name);
+
+ /* SET ENVIROMENT*/
+ __set_env(menu_info, kb);
+
+ return 0;
+}
+
+_static_ int __fake_launch_app(int cmd, int pid, bundle * kb)
+{
+ int datalen;
+ int ret;
+ bundle_raw *kb_data;
+
+ bundle_encode(kb, &kb_data, &datalen);
+ if ((ret = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
+ _E("error request fake launch - error code = %d", ret);
+ free(kb_data);
+ return ret;
+}
+
+_static_ char **__create_argc_argv(bundle * kb, int *margc)
+{
+ char **argv;
+ int argc;
+
+ argc = bundle_export_to_argv(kb, &argv);
+
+ *margc = argc;
+ return argv;
+}
+
+_static_ int __normal_fork_exec(int argc, char **argv)
+{
+ _D("start real fork and exec\n");
+
+ if (execv(argv[0], argv) < 0) { /* Flawfinder: ignore */
+ if (errno == EACCES)
+ _E("such a file is no executable - %s", argv[0]);
+ else
+ _E("unknown executable error - %s", argv[0]);
+ return -1;
+ }
+ /* never reach*/
+ return 0;
+}
+
+_static_ void __real_launch(const char *app_path, bundle * kb)
+{
+ int app_argc;
+ char **app_argv;
+ int i;
+
+ app_argv = __create_argc_argv(kb, &app_argc);
+ app_argv[0] = strdup(app_path);
+
+ for (i = 0; i < app_argc; i++)
+ _D("input argument %d : %s##", i, app_argv[i]);
+
+ PERF("setup argument done");
+ _E("lock up test log(no error) : setup argument done");
+
+ /* Temporary log: launch time checking */
+ LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:launchpad:done]", app_path);
+
+ __preload_exec(app_argc, app_argv);
+
+ __normal_fork_exec(app_argc, app_argv);
+}
+
+
+/*
+ * Parsing original app path to retrieve default bundle
+ *
+ * -1 : Invalid sequence
+ * -2 : Buffer overflow
+ *
+ */
+static inline int __parser(const char *arg, char *out, int out_size)
+{
+ register int i;
+ int state = 1;
+ char *start_out = out;
+
+ if (arg == NULL || out == NULL) {
+ /* Handles null buffer*/
+ return 0;
+ }
+
+ for (i = 0; out_size > 1; i++) {
+ switch (state) {
+ case 1:
+ switch (arg[i]) {
+ case ' ':
+ case '\t':
+ state = 5;
+ break;
+ case '\0':
+ state = 7;
+ break;
+ case '\"':
+ state = 2;
+ break;
+ case '\\':
+ state = 4;
+ break;
+ default:
+ *out = arg[i];
+ out++;
+ out_size--;
+ break;
+ }
+ break;
+ case 2: /* escape start*/
+ switch (arg[i]) {
+ case '\0':
+ state = 6;
+ break;
+ case '\"':
+ state = 1;
+ break;
+ default:
+ *out = arg[i];
+ out++;
+ out_size--;
+ break;
+ }
+ break;
+ case 4: /* character escape*/
+ if (arg[i] == '\0') {
+ state = 6;
+ } else {
+ *out = arg[i];
+ out++;
+ out_size--;
+ state = 1;
+ }
+ break;
+ case 5: /* token*/
+ if (out != start_out) {
+ *out = '\0';
+ out_size--;
+ return i;
+ }
+ i--;
+ state = 1;
+ break;
+ case 6:
+ return -1; /* error*/
+ case 7: /* terminate*/
+ *out = '\0';
+ out_size--;
+ return 0;
+ default:
+ state = 6;
+ break; /* error*/
+ }
+ }
+
+ if (out_size == 1) {
+ *out = '\0';
+ }
+ /* Buffer overflow*/
+ return -2;
+}
+
+_static_ void __modify_bundle(bundle * kb, int caller_pid,
+ app_info_from_db * menu_info, int cmd)
+{
+ bundle_del(kb, AUL_K_PKG_NAME);
+ bundle_del(kb, AUL_K_EXEC);
+ bundle_del(kb, AUL_K_PACKAGETYPE);
+ bundle_del(kb, AUL_K_HWACC);
+
+ /* Parse app_path to retrieve default bundle*/
+ if (cmd == APP_START || cmd == APP_START_RES || cmd == APP_OPEN || cmd == APP_RESUME) {
+ char *ptr;
+ char exe[MAX_PATH_LEN];
+ int flag;
+
+ ptr = _get_original_app_path(menu_info);
+
+ flag = __parser(ptr, exe, sizeof(exe));
+ if (flag > 0) {
+ char key[256];
+ char value[256];
+
+ ptr += flag;
+ _D("parsing app_path: EXEC - %s\n", exe);
+
+ do {
+ flag = __parser(ptr, key, sizeof(key));
+ if (flag <= 0)
+ break;
+ ptr += flag;
+
+ flag = __parser(ptr, value, sizeof(value));
+ if (flag < 0)
+ break;
+ ptr += flag;
+
+ /*bundle_del(kb, key);*/
+ bundle_add(kb, key, value);
+ } while (flag > 0);
+ } else if (flag == 0) {
+ _D("parsing app_path: No arguments\n");
+ } else {
+ _D("parsing app_path: Invalid argument\n");
+ }
+ }
+}
+
+_static_ int __child_raise_win_by_x(int pid, void *priv)
+{
+ return x_util_raise_win(pid);
+}
+
+_static_ int __raise_win_by_x(int pid)
+{
+ int pgid;
+ if (x_util_raise_win(pid) == 0)
+ return 0;
+
+ /* support app launched by shell script*/
+ pgid = getpgid(pid);
+ _D("X raise failed. try to find first child & raise it - c:%d p:%d\n",
+ pgid, pid);
+
+ if (pgid <= 1)
+ return -1;
+ if (__proc_iter_pgid(pgid, __child_raise_win_by_x, NULL) < 0)
+ return -1;
+
+ return 0;
+}
+
+_static_ int __send_to_sigkill(int pid)
+{
+ int pgid;
+
+ pgid = getpgid(pid);
+ if (pgid <= 1)
+ return -1;
+
+ if (killpg(pgid, SIGKILL) < 0)
+ return -1;
+
+ return 0;
+}
+
+_static_ int __term_app(int pid)
+{
+ int dummy;
+ if (__app_send_raw
+ (pid, APP_TERM_BY_PID, (unsigned char *)&dummy, sizeof(int)) < 0) {
+ _D("terminate packet send error - use SIGKILL");
+ if (__send_to_sigkill(pid) < 0) {
+ _E("fail to killing - %d\n", pid);
+ return -1;
+ }
+ }
+ _D("term done\n");
+ return 0;
+}
+
+_static_ int __resume_app(int pid)
+{
+ int dummy;
+ int ret;
+ if ((ret =
+ __app_send_raw(pid, APP_RESUME_BY_PID, (unsigned char *)&dummy,
+ sizeof(int))) < 0) {
+ if (ret == -EAGAIN)
+ _E("resume packet timeout error");
+ else {
+ _D("resume packet send error - use raise win");
+ if (__raise_win_by_x(pid) < 0) {
+ _E("raise failed - %d resume fail\n", pid);
+ _E("we will term the app - %d\n", pid);
+ __send_to_sigkill(pid);
+ ret = -1;
+ } else
+ ret = 0;
+ }
+ }
+ _D("resume done\n");
+ return ret;
+}
+
+static int __get_caller_pid(bundle *kb)
+{
+ const char *pid_str;
+ int pid;
+
+ pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID);
+ if(pid_str)
+ goto end;
+
+ pid_str = bundle_get_val(kb, AUL_K_CALLER_PID);
+ if (pid_str == NULL)
+ return -1;
+
+end:
+ pid = atoi(pid_str);
+ if (pid <= 1)
+ return -1;
+
+ return pid;
+}
+
+_static_ int __foward_cmd(int cmd, bundle *kb, int cr_pid)
+{
+ int pid;
+ char tmp_pid[MAX_PID_STR_BUFSZ];
+ int datalen;
+ bundle_raw *kb_data;
+ int res;
+
+ if ((pid = __get_caller_pid(kb)) < 0)
+ return AUL_R_ERROR;
+
+ snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", cr_pid);
+
+ bundle_add(kb, AUL_K_CALLEE_PID, tmp_pid);
+
+ bundle_encode(kb, &kb_data, &datalen);
+ if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0)
+ res = AUL_R_ERROR;
+
+ free(kb_data);
+
+ return res;
+}
+
+_static_ void __real_send(int clifd, int ret)
+{
+ if (send(clifd, &ret, sizeof(int), MSG_NOSIGNAL) < 0) {
+ if (errno == EPIPE) {
+ _E("send failed due to EPIPE.\n");
+ }
+ _E("send fail to client");
+ }
+
+ close(clifd);
+}
+
+_static_ void __send_result_to_caller(int clifd, int ret)
+{
+ char *cmdline;
+ int wait_count;
+ int cmdline_changed = 0;
+ int cmdline_exist = 0;
+
+ if (clifd == -1)
+ return;
+
+ if (ret <= 1) {
+ __real_send(clifd, ret);
+ return;
+ }
+ /* check normally was launched?*/
+ wait_count = 1;
+ do {
+ cmdline = __proc_get_cmdline_bypid(ret);
+ if (cmdline == NULL) {
+ _E("error founded when being launched with %d", ret);
+
+ } else if (strcmp(cmdline, launchpad_cmdline)) {
+ free(cmdline);
+ cmdline_changed = 1;
+ break;
+ } else {
+ cmdline_exist = 1;
+ free(cmdline);
+ }
+
+ _D("-- now wait to change cmdline --");
+ usleep(50 * 1000); /* 50ms sleep*/
+ wait_count++;
+ } while (wait_count <= 20); /* max 50*20ms will be sleep*/
+
+ if ((!cmdline_exist) && (!cmdline_changed)) {
+ __real_send(clifd, -1); /* abnormally launched*/
+ return;
+ }
+
+ if (!cmdline_changed)
+ _E("process launched, but cmdline not changed");
+
+ __real_send(clifd, ret);
+ return;
+}
+
+static app_info_from_db *_get_app_info_from_bundle_by_pkgname(
+ const char *pkgname, bundle *kb)
+{
+ app_info_from_db *menu_info;
+
+ menu_info = calloc(1, sizeof(app_info_from_db));
+ if (menu_info == NULL) {
+ return NULL;
+ }
+
+ menu_info->pkg_name = strdup(pkgname);
+ menu_info->app_path = strdup(bundle_get_val(kb, AUL_K_EXEC));
+ if (menu_info->app_path != NULL)
+ menu_info->original_app_path = strdup(menu_info->app_path);
+ menu_info->pkg_type = strdup(bundle_get_val(kb, AUL_K_PACKAGETYPE));
+ menu_info->hwacc = strdup(bundle_get_val(kb, AUL_K_HWACC));
+
+ if (!_get_app_path(menu_info)) {
+ _free_app_info_from_db(menu_info);
+ return NULL;
+ }
+
+ return menu_info;
+}
+
+_static_ void __launchpad_main_loop(int main_fd)
+{
+ bundle *kb = NULL;
+ app_pkt_t *pkt = NULL;
+ app_info_from_db *menu_info = NULL;
+
+ const char *pkg_name = NULL;
+ const char *app_path = NULL;
+ int pid = -1;
+ int clifd = -1;
+ struct ucred cr;
+ int is_real_launch = 0;
+
+ char sock_path[UNIX_PATH_MAX] = {0,};
+
+ pkt = __app_recv_raw(main_fd, &clifd, &cr);
+ if (!pkt) {
+ _D("packet is NULL");
+ goto end;
+ }
+
+ kb = bundle_decode(pkt->data, pkt->len);
+ if (!kb) {
+ _D("bundle decode error");
+ goto end;
+ }
+
+ INIT_PERF(kb);
+ PERF("packet processing start");
+
+ pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
+ _D("pkg name : %s\n", pkg_name);
+
+ menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb);
+ if (menu_info == NULL) {
+ _D("such pkg no found");
+ goto end;
+ }
+
+ app_path = _get_app_path(menu_info);
+ if(app_path == NULL) {
+ _E("app_path is NULL");
+ goto end;
+ }
+ if (app_path[0] != '/') {
+ _D("app_path is not absolute path");
+ goto end;
+ }
+
+ __modify_bundle(kb, cr.pid, menu_info, pkt->cmd);
+ pkg_name = _get_pkgname(menu_info);
+
+ PERF("get package information & modify bundle done");
+
+ {
+ pid = fork();
+ if (pid == 0) {
+ PERF("fork done");
+ _E("lock up test log(no error) : fork done");
+
+ close(clifd);
+ close(main_fd);
+ __signal_unset_sigchld();
+ __signal_fini();
+
+ snprintf(sock_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, getpid());
+ unlink(sock_path);
+
+ PERF("prepare exec - first done");
+ _E("lock up test log(no error) : prepare exec - first done");
+
+ if (__prepare_exec(pkg_name, app_path,
+ menu_info, kb) < 0) {
+ _E("preparing work fail to launch - "
+ "can not launch %s\n", pkg_name);
+ exit(-1);
+ }
+
+ PERF("prepare exec - second done");
+ _E("lock up test log(no error) : prepare exec - second done");
+
+ __real_launch(app_path, kb);
+
+ exit(-1);
+ }
+ _D("==> real launch pid : %d %s\n", pid, app_path);
+ is_real_launch = 1;
+ }
+
+ end:
+ __send_result_to_caller(clifd, pid);
+
+ if (pid > 0) {
+ if (is_real_launch) {
+ /*TODO: retry*/
+ __signal_block_sigchld();
+ __send_app_launch_signal(pid);
+ __signal_unblock_sigchld();
+ }
+ }
+
+ if (menu_info != NULL)
+ _free_app_info_from_db(menu_info);
+
+ if (kb != NULL)
+ bundle_free(kb);
+ if (pkt != NULL)
+ free(pkt);
+
+ /* Active Flusing for Daemon */
+ if (initialized > AUL_POLL_CNT) {
+ sqlite3_release_memory(SQLITE_FLUSH_MAX);
+ malloc_trim(0);
+ initialized = 1;
+ }
+
+}
+
+_static_ int __launchpad_pre_init(int argc, char **argv)
+{
+ int fd;
+
+ /* signal init*/
+ __signal_init();
+
+ /* get my(launchpad) command line*/
+ launchpad_cmdline = __proc_get_cmdline_bypid(getpid());
+ if (launchpad_cmdline == NULL) {
+ _E("launchpad cmdline fail to get");
+ return -1;
+ }
+ _D("launchpad cmdline = %s", launchpad_cmdline);
+
+ /* create launchpad sock */
+ fd = __create_server_sock(LAUNCHPAD_PID);
+ if (fd < 0) {
+ _E("server sock error");
+ return -1;
+ }
+
+ __preload_init(argc, argv);
+
+ __preexec_init(argc, argv);
+
+ return fd;
+}
+
+_static_ int __launchpad_post_init()
+{
+ /* Setting this as a global variable to keep track
+ of launchpad poll cnt */
+ /* static int initialized = 0;*/
+
+ if (initialized) {
+ initialized++;
+ return 0;
+ }
+
+ if (__signal_set_sigchld() < 0)
+ return -1;
+
+ initialized++;
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ int main_fd;
+ struct pollfd pfds[POLLFD_MAX];
+ int i;
+
+ /* init without concerning X & EFL*/
+ main_fd = __launchpad_pre_init(argc, argv);
+ if (main_fd < 0) {
+ _E("launchpad pre init failed");
+ exit(-1);
+ }
+
+ pfds[0].fd = main_fd;
+ pfds[0].events = POLLIN;
+ pfds[0].revents = 0;
+
+ while (1) {
+ if (poll(pfds, POLLFD_MAX, -1) < 0)
+ continue;
+
+ /* init with concerning X & EFL (because of booting
+ sequence problem)*/
+ if (__launchpad_post_init() < 0) {
+ _E("launcpad post init failed");
+ exit(-1);
+ }
+
+ for (i = 0; i < POLLFD_MAX; i++) {
+ if ((pfds[i].revents & POLLIN) != 0) {
+ __launchpad_main_loop(pfds[i].fd);
+ }
+ }
+ }
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <pthread.h>
+#include "app_signal.h"
+
+static struct sigaction old_sigchild;
+static DBusConnection *bus = NULL;
+sigset_t oldmask;
+
+static inline void __socket_garbage_collector()
+{
+ DIR *dp;
+ struct dirent *dentry;
+ char tmp[MAX_LOCAL_BUFSZ];
+
+ dp = opendir(AUL_SOCK_PREFIX);
+ if (dp == NULL)
+ return;
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ snprintf(tmp, MAX_LOCAL_BUFSZ, "/proc/%s", dentry->d_name);
+ if (access(tmp, F_OK) < 0) { /* Flawfinder: ignore */
+ snprintf(tmp, MAX_LOCAL_BUFSZ, "%s/%s", AUL_SOCK_PREFIX,
+ dentry->d_name);
+ unlink(tmp);
+ continue;
+ }
+ }
+ closedir(dp);
+}
+
+static inline int __send_app_dead_signal(int dead_pid)
+{
+ DBusMessage *message;
+
+ if (bus == NULL)
+ return -1;
+
+ message = dbus_message_new_signal(AUL_DBUS_PATH,
+ AUL_DBUS_SIGNAL_INTERFACE,
+ AUL_DBUS_APPDEAD_SIGNAL);
+
+ if (dbus_message_append_args(message,
+ DBUS_TYPE_UINT32, &dead_pid,
+ DBUS_TYPE_INVALID) == FALSE) {
+ _E("Failed to load data error");
+ return -1;
+ }
+
+ if (dbus_connection_send(bus, message, NULL) == FALSE) {
+ _E("dbus send error");
+ return -1;
+ }
+
+ dbus_connection_flush(bus);
+ dbus_message_unref(message);
+
+ _D("send dead signal done\n");
+
+ return 0;
+}
+
+static inline int __send_app_launch_signal(int launch_pid)
+{
+ DBusMessage *message;
+
+ if (bus == NULL)
+ return -1;
+
+ message = dbus_message_new_signal(AUL_DBUS_PATH,
+ AUL_DBUS_SIGNAL_INTERFACE,
+ AUL_DBUS_APPLAUNCH_SIGNAL);
+
+ if (dbus_message_append_args(message,
+ DBUS_TYPE_UINT32, &launch_pid,
+ DBUS_TYPE_INVALID) == FALSE) {
+ _E("Failed to load data error");
+ return -1;
+ }
+
+ if (dbus_connection_send(bus, message, NULL) == FALSE) {
+ _E("dbus send error");
+ return -1;
+ }
+
+ dbus_connection_flush(bus);
+ dbus_message_unref(message);
+
+ _D("send launch signal done\n");
+
+ return 0;
+}
+
+static int __sigchild_action(void *data)
+{
+ pid_t dead_pid;
+ char buf[MAX_LOCAL_BUFSZ];
+
+ dead_pid = (pid_t) data;
+ if (dead_pid <= 0)
+ goto end;
+
+ __send_app_dead_signal(dead_pid);
+
+ snprintf(buf, MAX_LOCAL_BUFSZ, "%s/%d", AUL_SOCK_PREFIX, dead_pid);
+ unlink(buf);
+
+ __socket_garbage_collector();
+ end:
+ return 0;
+}
+
+static void __launchpad_sig_child(int signo, siginfo_t *info, void *data)
+{
+ int status;
+ pid_t child_pid;
+ pid_t child_pgid;
+
+ child_pgid = getpgid(info->si_pid);
+ _D("dead_pid = %d pgid = %d", info->si_pid, child_pgid);
+
+ while ((child_pid = waitpid(-1, &status, WNOHANG)) > 0) {
+ if (child_pid == child_pgid)
+ killpg(child_pgid, SIGKILL);
+ __sigchild_action((void *)child_pid);
+ }
+
+ return;
+}
+
+static inline int __signal_init(void)
+{
+ int i;
+ for (i = 0; i < _NSIG; i++) {
+ switch (i) {
+ /* controlled by sys-assert package*/
+ case SIGQUIT:
+ case SIGILL:
+ case SIGABRT:
+ case SIGBUS:
+ case SIGFPE:
+ case SIGSEGV:
+ case SIGPIPE:
+ break;
+ default:
+ signal(i, SIG_DFL);
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static inline int __signal_set_sigchld(void)
+{
+ struct sigaction act;
+ DBusError error;
+
+ dbus_error_init(&error);
+ dbus_threads_init_default();
+ bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
+ if (!bus) {
+ _E("Failed to connect to the D-BUS daemon: %s", error.message);
+ dbus_error_free(&error);
+ return -1;
+ }
+ /* TODO: if process stop mechanism is included,
+ should be modified (SA_NOCLDSTOP)*/
+ act.sa_handler = NULL;
+ act.sa_sigaction = __launchpad_sig_child;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = SA_NOCLDSTOP | SA_SIGINFO;
+
+ if (sigaction(SIGCHLD, &act, &old_sigchild) < 0)
+ return -1;
+
+ return 0;
+}
+
+static inline int __signal_unset_sigchld(void)
+{
+ struct sigaction dummy;
+
+ if (bus == NULL)
+ return 0;
+
+ dbus_connection_close(bus);
+ if (sigaction(SIGCHLD, &old_sigchild, &dummy) < 0)
+ return -1;
+
+ return 0;
+}
+
+static inline int __signal_block_sigchld(void)
+{
+ sigset_t newmask;
+
+ sigemptyset(&newmask);
+ sigaddset(&newmask, SIGCHLD);
+
+ if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) {
+ _E("SIG_BLOCK error");
+ return -1;
+ }
+
+ _D("SIGCHLD blocked");
+
+ return 0;
+}
+
+static inline int __signal_unblock_sigchld(void)
+{
+ if(sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) {
+ _E("SIG_SETMASK error");
+ return -1;
+ }
+
+ _D("SIGCHLD unblocked");
+ return 0;
+}
+
+static inline int __signal_fini(void)
+{
+#ifndef PRELOAD_ACTIVATE
+ int i;
+ for (i = 0; i < _NSIG; i++)
+ signal(i, SIG_DFL);
+#endif
+ return 0;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+#include "simple_util.h"
+
+static Atom a_pid;
+static int (*x_old_error) (Display *, XErrorEvent *);
+
+
+static pid_t __get_win_pid(Display *d, Window win);
+static int __find_win(Display *d, Window *win, pid_t pid);
+static int __raise_win(Display *d, Window win);
+static int __cb_x_error(Display *disp, XErrorEvent *ev);
+
+static pid_t __get_win_pid(Display *d, Window win)
+{
+ int r;
+ pid_t pid;
+
+ Atom a_type;
+ int format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop_ret;
+
+ retv_if(d == NULL || !a_pid, -1);
+
+ prop_ret = NULL;
+ r = XGetWindowProperty(d, win, a_pid, 0, 1, False, XA_CARDINAL,
+ &a_type, &format, &nitems, &bytes_after, &prop_ret);
+ if (r != Success || prop_ret == NULL)
+ return -1;
+
+ if (a_type == XA_CARDINAL && format == 32)
+ pid = *(unsigned long *)prop_ret;
+ else
+ pid = -1;
+
+ XFree(prop_ret);
+
+ return pid;
+}
+
+static int __find_win(Display *d, Window *win, pid_t pid)
+{
+ int r;
+ pid_t p;
+ unsigned int n;
+ Window root, parent, *child;
+
+ p = __get_win_pid(d, *win);
+ if (p == pid)
+ return 1;
+
+ r = XQueryTree(d, *win, &root, &parent, &child, &n);
+ if (r) {
+ int i;
+ int found = 0;
+
+ for (i = 0; i < n; i++) {
+ found = __find_win(d, &child[i], pid);
+ if (found) {
+ *win = child[i];
+ break;
+ }
+ }
+ XFree(child);
+
+ if (found)
+ return 1;
+ }
+
+ return 0;
+}
+
+static int __raise_win(Display *d, Window win)
+{
+ XWindowAttributes attr;
+ attr.map_state = IsUnmapped;
+
+ XMapRaised(d, win);
+
+ XGetWindowAttributes(d, win, &attr);
+
+ if (attr.map_state == IsUnmapped)
+ _D("unmapped");
+ else if (attr.map_state == IsUnviewable)
+ _D("unviewable");
+ else if (attr.map_state == IsViewable)
+ _D("viewable");
+
+ retv_if(attr.map_state != IsViewable, -1);
+
+ XSetInputFocus(d, win, RevertToPointerRoot, CurrentTime);
+
+ return 0;
+}
+
+int x_util_raise_win(pid_t pid)
+{
+ int r;
+ int found;
+ Display *d;
+ Window win;
+
+ if (pid < 1)
+ return -1;
+
+ r = kill(pid, 0);
+ if (r == -1)
+ return -1;
+
+ d = XOpenDisplay(NULL);
+ retv_if(d == NULL, -1);
+
+ win = XDefaultRootWindow(d);
+
+ if (!a_pid)
+ a_pid = XInternAtom(d, "X_CLIENT_PID", True);
+
+ found = __find_win(d, &win, pid);
+ if (!found) {
+ XCloseDisplay(d);
+ _E("cannot found window with pid - %d", pid);
+ return -1;
+ }
+
+ r = __raise_win(d, win);
+ if (r < 0)
+ _E("fail to raise win");
+
+ XCloseDisplay(d);
+
+ return r;
+}
+
+int x_util_get_default_size(double *w, double *h)
+{
+ Display *d;
+ int screen_num;
+
+ d = XOpenDisplay(NULL);
+ if (d == NULL)
+ return -1;
+
+ screen_num = DefaultScreen(d);
+
+ *w = DisplayWidth(d, screen_num);
+ *h = DisplayHeight(d, screen_num);
+
+ _D("Root Width = %lf, Height = %lf\n", *w, *h);
+
+ XCloseDisplay(d);
+
+ return 0;
+}
+
+static int __cb_x_error(Display *disp, XErrorEvent *ev)
+{
+ _E("X error received - Error Code = %d", ev->error_code);
+ return 0;
+}
+
+int x_util_init()
+{
+ x_old_error = XSetErrorHandler(__cb_x_error);
+ return 0;
+}
+
+int x_util_fini()
+{
+ XSetErrorHandler(x_old_error);
+ return 0;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifndef __UTIL_X_H_
+#define __UTIL_X_H_
+
+int x_util_init();
+int x_util_fini();
+int x_util_get_default_size(double *w, double *h);
+int x_util_raise_win(pid_t pid);
+
+#endif
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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.
+ *
+ */
+
+
+#ifdef PRELOAD_ACTIVATE
+
+#include <dlfcn.h>
+#define PRELOAD_FILE SHARE_PREFIX"/preload_list.txt"
+
+#define EFL_PREINIT_FUNC "elm_quicklaunch_init"
+#define EFL_SHUTDOWN_FUNC "elm_quicklaunch_shutdown"
+
+static int preload_initialized = 0;
+static int g_argc;
+static char **g_argv;
+static int max_cmdline_size = 0;
+
+static int (*dl_einit) () = NULL;
+static int (*dl_efini) () = NULL;
+
+static inline void __preload_init(int argc, char **argv)
+{
+ void *handle = NULL;
+ char soname[MAX_LOCAL_BUFSZ];
+ FILE *preload_list;
+ int (*func)() = NULL;
+ int i;
+
+ g_argc = argc;
+ g_argv = argv;
+ for (i = 0; i < argc; i++) {
+ max_cmdline_size += (strlen(argv[i]) + 1);
+ }
+ _D("max_cmdline_size = %d", max_cmdline_size);
+
+ preload_list = fopen(PRELOAD_FILE, "rt");
+ if (preload_list == NULL) {
+ _E("no preload\n");
+ return;
+ }
+
+ while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) > 0) {
+ soname[strlen(soname) - 1] = 0;
+ handle = dlopen((const char *) soname, RTLD_NOW);
+ if (handle == NULL)
+ continue;
+ _D("preload %s# - handle : %x\n", soname, handle);
+
+ func = dlsym(handle, EFL_PREINIT_FUNC);
+ if (func != NULL) {
+ _D("get pre-initialization function\n");
+ dl_einit = func;
+ func = dlsym(handle, EFL_SHUTDOWN_FUNC);
+ if (func != NULL) {
+ _D("get shutdown function\n");
+ dl_efini = func;
+ }
+ }
+ }
+
+ fclose(preload_list);
+ preload_initialized = 1;
+}
+
+static inline int preinit_init()
+{
+ if (dl_einit != NULL)
+ dl_einit(0, NULL);
+ _D("pre-initialzation on");
+ return 0;
+}
+
+static inline int preinit_fini()
+{
+ if (dl_efini != NULL)
+ dl_efini();
+ _D("pre-initialization off");
+ return 0;
+}
+
+/* TODO : how to set cmdline gracefully ?? */
+static inline int __change_cmdline(char *cmdline)
+{
+ if (strlen(cmdline) > max_cmdline_size + 1) {
+ _E("cmdline exceed max size : %d", max_cmdline_size);
+ return -1;
+ }
+
+ memset(g_argv[0], '\0', max_cmdline_size);
+ snprintf(g_argv[0], max_cmdline_size, "%s", cmdline);
+
+ return 0;
+}
+
+static inline void __preload_exec(int argc, char **argv)
+{
+ void *handle = NULL;
+ int (*dl_main) (int, char **);
+
+ if (!preload_initialized)
+ return;
+
+ handle = dlopen(argv[0], RTLD_LAZY | RTLD_GLOBAL);
+ if (handle == NULL) {
+ return;
+ }
+
+ dl_main = dlsym(handle, "main");
+ if (dl_main != NULL) {
+ if (__change_cmdline(argv[0]) < 0) {
+ _E("change cmdline fail");
+ return;
+ }
+ dl_main(argc, argv);
+ } else {
+ _E("dlsym not founded. bad preloaded app - check fpie pie");
+ }
+
+ exit(0);
+}
+
+#else
+
+static inline void __preload_init();
+static inline void __preload_exec(int argc, char **argv);
+
+#endif
+
--- /dev/null
+/usr/lib/libappcore-efl.so.1
+/usr/lib/libappcore-common.so.1
+/usr/lib/ecore/immodules/libisf-imf-module.so
+/usr/lib/osp/libosp-appfw.so
--- /dev/null
+#
+# classical example of a socket activated service?
+#
+
+[Unit]
+Description=Start the Access Control server
+
+[Service]
+Environment=DISPLAY=:0
+ExecStartPre=-/bin/mkdir -m 1777 /tmp/alaunch
+ExecStart=/bin/sh -c 'while test ! -e /tmp/.X0-lock; do sleep 0.1; done; exec /usr/bin/amd'
+
+OOMScoreAdjust=-100
+
+[Install]
+WantedBy=graphical.target
--- /dev/null
+Name: aul
+Summary: App utility library
+Version: 0.0.240
+Release: 1
+Group: System/Libraries
+License: Apache License, Version 2.0
+Source0: %{name}-%{version}.tar.gz
+Source101: launchpad-preload@.service
+Source102: ac.service
+
+Requires(post): /sbin/ldconfig
+Requires(post): /usr/bin/systemctl
+Requires(postun): /sbin/ldconfig
+Requires(postun): /usr/bin/systemctl
+Requires(preun): /usr/bin/systemctl
+
+BuildRequires: cmake
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(x11)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(ail)
+BuildRequires: xdgmime-devel, pkgconfig(xdgmime)
+BuildRequires: pkgconfig(libprivilege-control)
+BuildRequires: pkgconfig(app-checker)
+BuildRequires: pkgconfig(app-checker-server)
+BuildRequires: pkgconfig(rua)
+BuildRequires: pkgconfig(ecore-x)
+BuildRequires: pkgconfig(ecore-input)
+BuildRequires: pkgconfig(utilX)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(pkgmgr-info)
+BuildRequires: pkgconfig(libsmack)
+BuildRequires: pkgconfig(app2sd)
+
+
+%description
+Application utility library
+
+%package devel
+Summary: App utility library (devel)
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+Application utility library (devel)
+
+
+%prep
+%setup -q
+
+%build
+cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+mkdir -p %{buildroot}/etc/init.d
+install -m 755 launchpad_run %{buildroot}/etc/init.d
+
+mkdir -p %{buildroot}/etc/rc.d/rc3.d
+mkdir -p %{buildroot}/etc/rc.d/rc4.d
+ln -sf ../../init.d/launchpad_run %{buildroot}/%{_sysconfdir}/rc.d/rc3.d/S34launchpad_run
+ln -sf ../../init.d/launchpad_run %{buildroot}/%{_sysconfdir}/rc.d/rc4.d/S80launchpad_run
+
+mkdir -p %{buildroot}/opt/dbspace
+sqlite3 %{buildroot}/opt/dbspace/.mida.db < %{buildroot}/usr/share/aul/mida_db.sql
+rm -rf %{buildroot}/usr/share/aul/mida_db.sql
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/graphical.target.wants
+install -m 0644 %SOURCE101 %{buildroot}%{_libdir}/systemd/system/launchpad-preload@.service
+install -m 0644 %SOURCE102 %{buildroot}%{_libdir}/systemd/system/ac.service
+ln -s ../launchpad-preload@.service %{buildroot}%{_libdir}/systemd/system/graphical.target.wants/launchpad-preload@app.service
+ln -s ../ac.service %{buildroot}%{_libdir}/systemd/system/graphical.target.wants/ac.service
+
+
+%preun
+if [ $1 == 0 ]; then
+ systemctl stop launchpad-preload@app.service
+ systemctl stop ac.service
+fi
+
+%post
+/sbin/ldconfig
+systemctl daemon-reload
+if [ $1 == 1 ]; then
+ systemctl restart launchpad-preload@app.service
+ systemctl restart ac.service
+fi
+
+%postun -p /sbin/ldconfig
+systemctl daemon-reload
+
+%files
+%manifest aul.manifest
+%attr(0644,root,root) %{_libdir}/libaul.so.0
+%attr(0644,root,root) %{_libdir}/libaul.so.0.1.0
+%{_sysconfdir}/init.d/launchpad_run
+%attr(0755,root,root) %{_bindir}/aul_service.sh
+%attr(0755,root,root) %{_bindir}/aul_service_test.sh
+%attr(0755,root,root) %{_sysconfdir}/rc.d/rc3.d/S34launchpad_run
+%attr(0755,root,root) %{_sysconfdir}/rc.d/rc4.d/S80launchpad_run
+%config(noreplace) %attr(0644,root,app) /opt/dbspace/.mida.db
+%config(noreplace) %attr(0644,root,app) /opt/dbspace/.mida.db-journal
+%attr(0755,root,root) %{_bindir}/aul_mime.sh
+%{_bindir}/aul_test
+%{_bindir}/launch_app
+/usr/share/aul/miregex/*
+/usr/share/aul/service/*
+/usr/share/aul/preload_list.txt
+/usr/share/aul/preexec_list.txt
+%{_bindir}/launchpad_preloading_preinitializing_daemon
+%{_libdir}/systemd/system/graphical.target.wants/launchpad-preload@app.service
+%{_libdir}/systemd/system/graphical.target.wants/ac.service
+%{_libdir}/systemd/system/launchpad-preload@.service
+%{_libdir}/systemd/system/ac.service
+/usr/bin/amd
+/usr/bin/daemon-manager-release-agent
+/usr/bin/daemon-manager-launch-agent
+
+%files devel
+/usr/include/aul/*.h
+%{_libdir}/*.so
+%{_libdir}/pkgconfig/*.pc
--- /dev/null
+[Unit]
+Description=Start the preload/preinit daemon
+
+[Service]
+EnvironmentFile=/etc/sysconfig/tizen-mobile-ui
+Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/%I/dbus/user_bus_socket
+Environment=DISPLAY=:0
+Environment=XDG_RUNTIME_DIR=/run/user/%I
+ExecStart=/usr/bin/launchpad_preloading_preinitializing_daemon " "
+
+[Install]
+WantedBy=graphical.target
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include "app_signal.h"
+#include "aul_api.h"
+#include "simple_util.h"
+#include "aul.h"
+
+static int (*_app_dead_handler) (int pid, void *data);
+static void *_app_dead_data;
+
+static int (*_app_launch_handler) (int pid, void *data);
+static void *_app_launch_data;
+
+static DBusConnection *bus;
+static int app_dbus_signal_handler_initialized = 0;
+
+static DBusHandlerResult
+__app_dbus_signal_filter(DBusConnection *conn, DBusMessage *message,
+ void *user_data)
+{
+ const char *sender;
+ const char *interface;
+ int pid;
+
+ DBusError error;
+ dbus_error_init(&error);
+
+ sender = dbus_message_get_sender(message);
+ if (sender == NULL)
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+
+ if (dbus_bus_get_unix_user(conn, sender, &error) != 0) {
+ _E("reject by security issue - no allowed sender\n");
+ dbus_error_free(&error);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ interface = dbus_message_get_interface(message);
+ if (interface == NULL) {
+ _E("reject by security issue - no interface\n");
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ if (dbus_message_is_signal(
+ message, interface, AUL_DBUS_APPDEAD_SIGNAL)) {
+ if (dbus_message_get_args(message, &error, DBUS_TYPE_UINT32,
+ &pid, DBUS_TYPE_INVALID) == FALSE) {
+ _E("Failed to get data: %s", error.message);
+ dbus_error_free(&error);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+ if (_app_dead_handler)
+ _app_dead_handler(pid, _app_dead_data);
+ } else if (dbus_message_is_signal(
+ message, interface, AUL_DBUS_APPLAUNCH_SIGNAL)) {
+ if (dbus_message_get_args(message, &error, DBUS_TYPE_UINT32,
+ &pid, DBUS_TYPE_INVALID) == FALSE) {
+ _E("Failed to get data: %s", error.message);
+ dbus_error_free(&error);
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+ if (_app_launch_handler)
+ _app_launch_handler(pid, _app_launch_data);
+ }
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+int __app_dbus_signal_handler_init()
+{
+ DBusError error;
+ char rule[MAX_LOCAL_BUFSZ];
+
+ if (app_dbus_signal_handler_initialized)
+ return 0;
+
+ dbus_error_init(&error);
+ bus = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error);
+ if (!bus) {
+ _E("Failed to connect to the D-BUS daemon: %s", error.message);
+ dbus_error_free(&error);
+ return -1;
+ }
+ dbus_connection_setup_with_g_main(bus, NULL);
+
+ snprintf(rule, MAX_LOCAL_BUFSZ,
+ "path='%s',type='signal',interface='%s'", AUL_DBUS_PATH,
+ AUL_DBUS_SIGNAL_INTERFACE);
+ /* listening to messages */
+ dbus_bus_add_match(bus, rule, &error);
+ if (dbus_error_is_set(&error)) {
+ _E("Fail to rule set: %s", error.message);
+ dbus_error_free(&error);
+ return -1;
+ }
+
+ if (dbus_connection_add_filter(bus,
+ __app_dbus_signal_filter, NULL, NULL) == FALSE)
+ return -1;
+
+ app_dbus_signal_handler_initialized = 1;
+
+ _D("app signal initialized");
+
+ return 0;
+}
+
+int __app_dbus_signal_handler_fini()
+{
+ DBusError error;
+ char rule[MAX_LOCAL_BUFSZ];
+
+ if (!app_dbus_signal_handler_initialized)
+ return 0;
+
+ dbus_error_init(&error);
+
+ dbus_connection_remove_filter(bus, __app_dbus_signal_filter, NULL);
+
+ snprintf(rule, MAX_LOCAL_BUFSZ,
+ "path='%s',type='signal',interface='%s'", AUL_DBUS_PATH,
+ AUL_DBUS_SIGNAL_INTERFACE);
+ dbus_bus_remove_match(bus, rule, &error);
+ if (dbus_error_is_set(&error)) {
+ _E("Fail to rule unset: %s", error.message);
+ dbus_error_free(&error);
+ return -1;
+ }
+
+ dbus_connection_close(bus);
+ dbus_connection_unref(bus);
+
+ app_dbus_signal_handler_initialized = 0;
+
+ _D("app signal finialized");
+
+ return 0;
+}
+
+SLPAPI int aul_listen_app_dead_signal(int (*func) (int, void *), void *data)
+{
+ if (func) {
+ if (__app_dbus_signal_handler_init() < 0) {
+ _E("error app signal init");
+ return AUL_R_ERROR;
+ }
+ } else if (_app_launch_handler == NULL) {
+ if (__app_dbus_signal_handler_fini() < 0) {
+ _E("error app signal fini");
+ return AUL_R_ERROR;
+ }
+ }
+ _app_dead_handler = func;
+ _app_dead_data = data;
+
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_listen_app_launch_signal(int (*func) (int, void *), void *data)
+{
+ if (func) {
+ if (__app_dbus_signal_handler_init() < 0) {
+ _E("error app signal init");
+ return AUL_R_ERROR;
+ }
+ } else if (_app_dead_handler == NULL) {
+ if (__app_dbus_signal_handler_fini() < 0) {
+ _E("error app signal fini");
+ return AUL_R_ERROR;
+ }
+ }
+ _app_launch_handler = func;
+ _app_launch_data = data;
+
+ return AUL_R_OK;
+}
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/smack.h>
+#include <errno.h>
+#include <fcntl.h>
+
+#include "app_sock.h"
+#include "simple_util.h"
+
+static int __connect_client_sock(int sockfd, const struct sockaddr *saptr, socklen_t salen,
+ int nsec);
+
+
+static inline void __set_sock_option(int fd, int cli)
+{
+ int size;
+ struct timeval tv = { 3, 200 * 1000 }; /* 3.2 sec */
+
+ size = AUL_SOCK_MAXBUFF;
+ setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
+ setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+ if (cli)
+ setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+}
+
+int __create_server_sock(int pid)
+{
+ struct sockaddr_un saddr;
+ struct sockaddr_un p_saddr;
+ int fd;
+ mode_t orig_mask;
+
+ /* Create basedir for our sockets */
+ orig_mask = umask(0);
+ (void) mkdir(AUL_SOCK_PREFIX, S_IRWXU | S_IRWXG | S_IRWXO | S_ISVTX);
+ umask(orig_mask);
+
+ fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ /* support above version 2.6.27*/
+ if (fd < 0) {
+ if (errno == EINVAL) {
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ _E("second chance - socket create error");
+ return -1;
+ }
+ } else {
+ _E("socket error");
+ return -1;
+ }
+ }
+
+ memset(&saddr, 0, sizeof(saddr));
+ saddr.sun_family = AF_UNIX;
+ snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
+ unlink(saddr.sun_path);
+
+ /* labeling to socket for SMACK */
+ if(getuid() == 0) { // this is meaningful iff current user is ROOT
+ if(smack_fsetlabel(fd, "@", SMACK_LABEL_IPOUT) != 0) {
+ /* in case of unsupported filesystem on 'socket' */
+ /* or permission error by using 'emulator', bypass*/
+ if((errno != EOPNOTSUPP) && (errno != EPERM)) {
+ _E("labeling to socket(IPOUT) error");
+ close(fd);
+ return -1;
+ }
+ }
+ if(smack_fsetlabel(fd, "*", SMACK_LABEL_IPIN) != 0) {
+ /* in case of unsupported filesystem on 'socket' */
+ /* or permission error by using 'emulator', bypass*/
+ if((errno != EOPNOTSUPP) && (errno != EPERM)) {
+ _E("labeling to socket(IPIN) error");
+ close(fd);
+ return -1;
+ }
+ }
+ }
+
+ if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+ _E("bind error");
+ close(fd);
+ return -1;
+ }
+
+ if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+ /* Flawfinder: ignore*/
+ _E("failed to change the socket permission");
+ close(fd);
+ return -1;
+ }
+
+ __set_sock_option(fd, 0);
+
+ if (listen(fd, 10) == -1) {
+ _E("listen error");
+ close(fd);
+ return -1;
+ }
+
+ /* support app launched by shell script */
+ if (pid != LAUNCHPAD_PID) {
+ int pgid;
+ pgid = getpgid(pid);
+ if (pgid > 1) {
+ snprintf(p_saddr.sun_path, UNIX_PATH_MAX, "%s/%d",
+ AUL_SOCK_PREFIX, pgid);
+ if (link(saddr.sun_path, p_saddr.sun_path) < 0) {
+ if (errno == EEXIST)
+ _D("pg path - already exists");
+ else
+ _E("pg path - unknown create error");
+ }
+ }
+ }
+
+ return fd;
+}
+
+int __create_client_sock(int pid)
+{
+ int fd = -1;
+ struct sockaddr_un saddr = { 0, };
+ int retry = 1;
+ int ret = -1;
+
+ fd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+ /* support above version 2.6.27*/
+ if (fd < 0) {
+ if (errno == EINVAL) {
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0) {
+ _E("second chance - socket create error");
+ return -1;
+ }
+ } else {
+ _E("socket error");
+ return -1;
+ }
+ }
+
+ saddr.sun_family = AF_UNIX;
+ snprintf(saddr.sun_path, UNIX_PATH_MAX, "%s/%d", AUL_SOCK_PREFIX, pid);
+ retry_con:
+ ret = __connect_client_sock(fd, (struct sockaddr *)&saddr, sizeof(saddr),
+ 100 * 1000);
+ if (ret < -1) {
+ _E("maybe peer not launched or peer daed\n");
+ if (retry > 0) {
+ usleep(100 * 1000);
+ retry--;
+ goto retry_con;
+ }
+ }
+ if (ret < 0) {
+ close(fd);
+ return -1;
+ }
+
+ __set_sock_option(fd, 1);
+
+ return fd;
+}
+
+static int __connect_client_sock(int fd, const struct sockaddr *saptr, socklen_t salen,
+ int nsec)
+{
+ int flags;
+ int ret;
+ int error;
+ socklen_t len;
+ fd_set readfds;
+ fd_set writefds;
+ struct timeval timeout;
+
+ flags = fcntl(fd, F_GETFL, 0);
+ fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+
+ error = 0;
+ if ((ret = connect(fd, (struct sockaddr *)saptr, salen)) < 0) {
+ if (errno != EAGAIN && errno != EINPROGRESS) {
+ fcntl(fd, F_SETFL, flags);
+ return (-2);
+ }
+ }
+
+ /* Do whatever we want while the connect is taking place. */
+ if (ret == 0)
+ goto done; /* connect completed immediately */
+
+ FD_ZERO(&readfds);
+ FD_SET(fd, &readfds);
+ writefds = readfds;
+ timeout.tv_sec = 0;
+ timeout.tv_usec = nsec;
+
+ if ((ret = select(fd + 1, &readfds, &writefds, NULL,
+ nsec ? &timeout : NULL)) == 0) {
+ close(fd); /* timeout */
+ errno = ETIMEDOUT;
+ return (-1);
+ }
+
+ if (FD_ISSET(fd, &readfds) || FD_ISSET(fd, &writefds)) {
+ len = sizeof(error);
+ if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0)
+ return (-1); /* Solaris pending error */
+ } else
+ return (-1); /* select error: sockfd not set*/
+
+ done:
+ (void) fcntl(fd, F_SETFL, flags);
+ if (error) {
+ close(fd);
+ errno = error;
+ return (-1);
+ }
+ return (0);
+}
+
+/**
+ * @brief Send data (in raw) to the process with 'pid' via socket
+ */
+int __app_send_raw(int pid, int cmd, unsigned char *kb_data, int datalen)
+{
+ int fd;
+ int len;
+ int res = 0;
+ app_pkt_t *pkt = NULL;
+
+ if (kb_data == NULL || datalen > AUL_SOCK_MAXBUFF - 8) {
+ _E("keybundle error\n");
+ return -EINVAL;
+ }
+
+ fd = __create_client_sock(pid);
+ if (fd < 0)
+ return -ECOMM;
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if (NULL == pkt) {
+ _E("Malloc Failed!");
+ return -ENOMEM;
+ }
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ pkt->cmd = cmd;
+ pkt->len = datalen;
+ memcpy(pkt->data, kb_data, datalen);
+
+ if ((len = send(fd, pkt, datalen + 8, 0)) != datalen + 8) {
+ _E("sendto() failed - %d %d (errno %d)", len, datalen + 8, errno);
+ if (errno == EPIPE) {
+ _E("pid:%d, fd:%d\n", pid, fd);
+ }
+ close(fd);
+ if (pkt) {
+ free(pkt);
+ pkt = NULL;
+ }
+ return -ECOMM;
+ }
+ if (pkt) {
+ free(pkt);
+ pkt = NULL;
+ }
+
+ len = recv(fd, &res, sizeof(int), 0);
+ if (len == -1) {
+ if (errno == EAGAIN) {
+ _E("recv timeout \n");
+ res = -EAGAIN;
+ } else {
+ _E("recv error\n");
+ res = -ECOMM;
+ }
+ }
+ close(fd);
+
+ return res;
+}
+
+app_pkt_t *__app_recv_raw(int fd, int *clifd, struct ucred *cr)
+{
+ int len;
+ struct sockaddr_un aul_addr = { 0, };
+ int sun_size;
+ app_pkt_t *pkt = NULL;
+ int cl = sizeof(struct ucred);
+
+ sun_size = sizeof(struct sockaddr_un);
+
+ if ((*clifd = accept(fd, (struct sockaddr *)&aul_addr,
+ (socklen_t *) &sun_size)) == -1) {
+ if (errno != EINTR)
+ _E("accept error");
+ return NULL;
+ }
+
+ if (getsockopt(*clifd, SOL_SOCKET, SO_PEERCRED, cr,
+ (socklen_t *) &cl) < 0) {
+ _E("peer information error");
+ close(*clifd);
+ return NULL;
+ }
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if(pkt == NULL) {
+ close(*clifd);
+ return NULL;
+ }
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ __set_sock_option(*clifd, 1);
+
+ retry_recv:
+ /* receive single packet from socket */
+ len = recv(*clifd, pkt, AUL_SOCK_MAXBUFF, 0);
+ if (len < 0)
+ if (errno == EINTR)
+ goto retry_recv;
+
+ if ((len < 8) || (len != (pkt->len + 8))) {
+ _E("recv error %d %d", len, pkt->len);
+ free(pkt);
+ close(*clifd);
+ return NULL;
+ }
+
+ return pkt;
+}
+
+app_pkt_t *__app_send_cmd_with_result(int pid, int cmd)
+{
+ int fd;
+ int len;
+ app_pkt_t *pkt = NULL;
+
+ fd = __create_client_sock(pid);
+ if (fd < 0)
+ return NULL;
+
+ pkt = (app_pkt_t *) malloc(sizeof(char) * AUL_SOCK_MAXBUFF);
+ if (NULL == pkt) {
+ _E("Malloc Failed!");
+ return NULL;
+ }
+ memset(pkt, 0, AUL_SOCK_MAXBUFF);
+
+ pkt->cmd = cmd;
+ pkt->len = 0;
+
+ if ((len = send(fd, pkt, 8, 0)) != 8) {
+ _E("sendto() failed - %d", len);
+ if (errno == EPIPE) {
+ _E("pid:%d, fd:%d\n", pid, fd);
+ }
+ close(fd);
+
+ free(pkt);
+ return NULL;
+ }
+
+retry_recv:
+ /* receive single packet from socket */
+ len = recv(fd, pkt, AUL_SOCK_MAXBUFF, 0);
+ if (len == -1) {
+ if (errno == EAGAIN) {
+ _E("recv timeout \n");
+ free(pkt);
+ return NULL;
+ } else if (errno == EINTR) {
+ goto retry_recv;
+ } else {
+ _E("recv error %s\n", strerror(errno));
+ free(pkt);
+ return NULL;
+ }
+ } else
+ _D("recv result = %d", len);
+ close(fd);
+
+ return pkt;
+}
+
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <utilX.h>
+#include <glib.h>
+#include <poll.h>
+#include <bundle.h>
+
+#include "aul.h"
+#include "aul_api.h"
+#include "menu_db_util.h"
+#include "simple_util.h"
+#include "app_sock.h"
+#include "aul_util.h"
+#include "launch.h"
+
+
+static int (*_aul_key_handler) (bundle *kb, void *data) = NULL;
+static void *_aul_key_data = NULL;
+
+extern GSourceFuncs funcs;
+
+int app_key_event(bundle *kb)
+{
+ if (_aul_key_handler)
+ _aul_key_handler(kb, _aul_key_data);
+ return 0;
+}
+
+int aul_register_key_init_callback(
+ int (*aul_handler) (bundle *, void *), void *data)
+{
+ /* Save start handler function in static var */
+ _aul_key_handler = aul_handler;
+ _aul_key_data = data;
+ return 0;
+}
+
+SLPAPI int aul_key_init(int (*aul_handler) (bundle *, void *), void *data)
+{
+ int fd;
+ GPollFD *gpollfd;
+ GSource *src;
+ int ret;
+
+ if (aul_handler != NULL)
+ aul_register_key_init_callback(aul_handler, data);
+
+ fd = aul_initialize();
+ if (fd < 0)
+ return fd;
+
+ src = g_source_new(&funcs, sizeof(GSource));
+
+ gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+ gpollfd->events = POLLIN;
+ gpollfd->fd = fd;
+
+ g_source_add_poll(src, gpollfd);
+ g_source_set_callback(src, (GSourceFunc) __aul_glib_handler,
+ (gpointer) gpollfd, NULL);
+ g_source_set_priority(src, G_PRIORITY_LOW);
+
+ ret = g_source_attach(src, NULL);
+ if (ret == 0)
+ return AUL_R_ERROR;
+
+ g_source_unref(src);
+
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_key_reserve()
+{
+ bundle *kb;
+ int ret;
+
+ kb = bundle_create();
+ ret = app_send_cmd(AUL_UTIL_PID, APP_KEY_RESERVE, kb);
+ bundle_free(kb);
+
+ return ret;
+}
+
+SLPAPI int aul_key_release()
+{
+ bundle *kb;
+ int ret;
+
+ kb = bundle_create();
+ ret = app_send_cmd(AUL_UTIL_PID, APP_KEY_RELEASE, kb);
+ bundle_free(kb);
+
+ return ret;
+}
+
+
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <glib.h>
+
+#include "aul.h"
+#include "aul_api.h"
+#include "app_sock.h"
+#include "perf.h"
+#include "simple_util.h"
+#include "launch.h"
+#include "key.h"
+#include "aul_util.h"
+
+static int aul_initialized = 0;
+static int aul_fd;
+
+static int (*_aul_handler) (aul_type type, bundle *kb, void *data) = NULL;
+static void *_aul_data;
+
+
+
+static int __call_aul_handler(aul_type type, bundle *kb);
+static int app_resume();
+static int app_terminate();
+static void __clear_internal_key(bundle *kb);
+static inline void __set_stime(bundle *kb);
+static int __app_start_internal(gpointer data);
+static int __app_launch_local(bundle *b);
+static int __send_result_to_launchpad(int fd, int res);
+
+extern int aul_launch_fini();
+
+int aul_is_initialized()
+{
+ return aul_initialized;
+}
+
+static int __call_aul_handler(aul_type type, bundle *kb)
+{
+ if (_aul_handler)
+ _aul_handler(type, kb, _aul_data);
+ return 0;
+}
+
+int app_start(bundle *kb)
+{
+ _app_start_res_prepare(kb);
+ __call_aul_handler(AUL_START, kb);
+ return 0;
+}
+
+static int app_resume()
+{
+ __call_aul_handler(AUL_RESUME, NULL);
+ return 0;
+}
+
+static int app_terminate()
+{
+ __call_aul_handler(AUL_TERMINATE, NULL);
+ return 0;
+}
+
+/**
+ * @brief encode kb and send it to 'pid'
+ * @param[in] pid receiver's pid
+ * @param[in] cmd message's status (APP_START | APP_RESULT)
+ * @param[in] kb data
+ */
+SLPAPI int app_send_cmd(int pid, int cmd, bundle *kb)
+{
+ int datalen;
+ bundle_raw *kb_data;
+ int res;
+
+ bundle_encode(kb, &kb_data, &datalen);
+ if ((res = __app_send_raw(pid, cmd, kb_data, datalen)) < 0) {
+ switch (res) {
+ case -EINVAL:
+ res = AUL_R_EINVAL;
+ break;
+ case -ECOMM:
+ res = AUL_R_ECOMM;
+ break;
+ case -EAGAIN:
+ res = AUL_R_ETIMEOUT;
+ break;
+ case -ELOCALLAUNCH_ID:
+ res = AUL_R_LOCAL;
+ break;
+ default:
+ res = AUL_R_ERROR;
+ }
+ }
+ free(kb_data);
+
+ return res;
+}
+
+static void __clear_internal_key(bundle *kb)
+{
+ bundle_del(kb, AUL_K_CALLER_PID);
+ bundle_del(kb, AUL_K_PKG_NAME);
+ bundle_del(kb, AUL_K_WAIT_RESULT);
+ bundle_del(kb, AUL_K_SEND_RESULT);
+ bundle_del(kb, AUL_K_ARGV0);
+}
+
+static inline void __set_stime(bundle *kb)
+{
+ struct timeval tv;
+ char tmp[MAX_LOCAL_BUFSZ];
+
+ gettimeofday(&tv, NULL);
+ snprintf(tmp, MAX_LOCAL_BUFSZ, "%ld/%ld", tv.tv_sec, tv.tv_usec);
+ bundle_add(kb, AUL_K_STARTTIME, tmp);
+}
+
+static int __app_start_internal(gpointer data)
+{
+ bundle *kb;
+
+ kb = (bundle *) data;
+ app_start(kb);
+ bundle_free(kb);
+
+ return 0;
+}
+
+static int __app_launch_local(bundle *b)
+{
+ if (!aul_is_initialized())
+ return AUL_R_ENOINIT;
+
+ if (b == NULL) {
+ _E("bundle for APP_START is NULL");
+ }
+ if (g_idle_add(__app_start_internal, b) > 0)
+ return AUL_R_OK;
+ else
+ return AUL_R_ERROR;
+}
+
+static int __app_resume_local()
+{
+ if (!aul_is_initialized())
+ return AUL_R_ENOINIT;
+
+ app_resume();
+
+ return 0;
+}
+
+/**
+ * @brief start caller with kb
+ * @return callee's pid
+ */
+int app_request_to_launchpad(int cmd, const char *pkgname, bundle *kb)
+{
+ int must_free = 0;
+ int ret = 0;
+
+ _D("launch request : %s", pkgname);
+ if (kb == NULL) {
+ kb = bundle_create();
+ must_free = 1;
+ } else
+ __clear_internal_key(kb);
+
+ bundle_add(kb, AUL_K_PKG_NAME, pkgname);
+ __set_stime(kb);
+ ret = app_send_cmd(AUL_UTIL_PID, cmd, kb);
+
+ _D("launch request result : %d", ret);
+ if (ret == AUL_R_LOCAL) {
+ _E("app_request_to_launchpad : Same Process Send Local");
+ bundle *b;
+
+ switch (cmd) {
+ case APP_START:
+ case APP_START_RES:
+ b = bundle_dup(kb);
+ ret = __app_launch_local(b);
+ break;
+ case APP_OPEN:
+ case APP_RESUME:
+ case APP_RESUME_BY_PID:
+ ret = __app_resume_local();
+ break;
+ default:
+ _E("no support packet");
+ }
+
+ }
+
+ /* cleanup */
+ if (must_free)
+ bundle_free(kb);
+
+ return ret;
+}
+
+static int __send_result_to_launchpad(int fd, int res)
+{
+ if (send(fd, &res, sizeof(int), MSG_NOSIGNAL) < 0) {
+ if (errno == EPIPE)
+ _E("send failed due to EPIPE.\n");
+ _E("send fail to client");
+ }
+ close(fd);
+ return 0;
+}
+
+/**
+ * @brief caller & callee's sock handler
+ */
+int aul_sock_handler(int fd)
+{
+ app_pkt_t *pkt;
+ bundle *kbundle;
+ int clifd;
+ struct ucred cr;
+
+ const char *pid_str;
+ int pid;
+
+ if ((pkt = __app_recv_raw(fd, &clifd, &cr)) == NULL) {
+ _E("recv error");
+ return -1;
+ }
+
+ if (pkt->cmd != APP_RESULT && pkt->cmd != APP_CANCEL && cr.uid != 0) {
+ _E("security error");
+ __send_result_to_launchpad(clifd, -1);
+ free(pkt);
+ return -1;
+ }
+
+ __send_result_to_launchpad(clifd, 0);
+
+ switch (pkt->cmd) {
+ case APP_START: /* run in callee */
+ case APP_START_RES:
+ kbundle = bundle_decode(pkt->data, pkt->len);
+ if (kbundle == NULL)
+ goto err;
+ app_start(kbundle);
+ bundle_free(kbundle);
+ break;
+
+ case APP_OPEN: /* run in callee */
+ case APP_RESUME:
+ case APP_RESUME_BY_PID:
+ app_resume();
+ break;
+
+ case APP_TERM_BY_PID: /* run in callee */
+ app_terminate();
+ break;
+
+ case APP_RESULT: /* run in caller */
+ case APP_CANCEL:
+ kbundle = bundle_decode(pkt->data, pkt->len);
+ if (kbundle == NULL)
+ goto err;
+
+ pid_str = bundle_get_val(kbundle, AUL_K_CALLEE_PID);
+ pid = atoi(pid_str);
+
+ app_result(pkt->cmd, kbundle, pid);
+ bundle_free(kbundle);
+ break;
+
+ case APP_KEY_EVENT: /* run in caller */
+ kbundle = bundle_decode(pkt->data, pkt->len);
+ if (kbundle == NULL)
+ goto err;
+ app_key_event(kbundle);
+ bundle_free(kbundle);
+ break;
+
+ default:
+ _E("no support packet");
+ }
+
+ free(pkt);
+ return 0;
+
+err:
+ free(pkt);
+ return -1;
+}
+
+int aul_make_bundle_from_argv(int argc, char **argv, bundle **kb)
+{
+ int ac = 1;
+
+ char *buf = NULL;
+
+ *kb = bundle_create();
+ if (*kb == NULL)
+ return AUL_R_ERROR;
+
+ if (argv == NULL)
+ return AUL_R_OK;
+
+ if ((argv != NULL) && (argv[0] != NULL)) {
+ buf = strdup(argv[0]);
+ if (NULL == buf) {
+ _E("Malloc failed");
+ return AUL_R_ERROR;
+ }
+
+ bundle_add(*kb, AUL_K_ARGV0, buf);
+ }
+ if (buf) { /*Prevent FIX: ID 38717 */
+ free(buf);
+ buf = NULL;
+ }
+
+ while (ac < argc) {
+ if (ac + 1 == argc) {
+ if (bundle_add(*kb, argv[ac], "") < 0) {
+ _E("bundle add error pos - %d", ac);
+ return AUL_R_ECANCELED;
+ }
+ } else {
+ if (bundle_add(*kb, argv[ac], argv[ac + 1]) < 0) {
+ _E("bundle add error pos - %d", ac);
+ return AUL_R_ECANCELED;
+ }
+ }
+ ac = ac + 2;
+ }
+
+ return AUL_R_OK;
+}
+
+int aul_register_init_callback(
+ int (*aul_handler) (aul_type type, bundle *, void *), void *data)
+{
+ /* Save start handler function in static var */
+ _aul_handler = aul_handler;
+ _aul_data = data;
+ return 0;
+}
+
+int aul_initialize()
+{
+ if (aul_initialized) {
+ _E("aul already initialized");
+ return AUL_R_ECANCELED;
+ }
+
+ aul_fd = __create_server_sock(getpid());
+ if (aul_fd < 0) {
+ _E("aul_init create sock failed");
+ return AUL_R_ECOMM;
+ }
+ aul_initialized = 1;
+
+ return aul_fd;
+}
+
+SLPAPI void aul_finalize()
+{
+ int ret;
+
+ aul_launch_fini();
+
+ if (aul_initialized) {
+ ret = close(aul_fd);
+ }
+
+ return;
+}
+
+
+SLPAPI int aul_launch_app(const char *appid, bundle *kb)
+{
+ int ret;
+
+ if (appid == NULL)
+ return AUL_R_EINVAL;
+
+ ret = app_request_to_launchpad(APP_START, appid, kb);
+ return ret;
+}
+
+SLPAPI int aul_open_app(const char *appid)
+{
+ int ret;
+
+ if (appid == NULL)
+ return AUL_R_EINVAL;
+
+ ret = app_request_to_launchpad(APP_OPEN, appid, NULL);
+ return ret;
+}
+
+SLPAPI int aul_resume_app(const char *appid)
+{
+ int ret;
+
+ if (appid == NULL)
+ return AUL_R_EINVAL;
+
+ ret = app_request_to_launchpad(APP_RESUME, appid, NULL);
+ return ret;
+}
+
+SLPAPI int aul_resume_pid(int pid)
+{
+ char pkgname[MAX_PID_STR_BUFSZ];
+ int ret;
+
+ if (pid <= 0)
+ return AUL_R_EINVAL;
+
+ snprintf(pkgname, MAX_PID_STR_BUFSZ, "%d", pid);
+ ret = app_request_to_launchpad(APP_RESUME_BY_PID, pkgname, NULL);
+ return ret;
+}
+
+SLPAPI int aul_terminate_pid(int pid)
+{
+ char pkgname[MAX_PID_STR_BUFSZ];
+ int ret;
+
+ if (pid <= 0)
+ return AUL_R_EINVAL;
+
+ snprintf(pkgname, MAX_PID_STR_BUFSZ, "%d", pid);
+ ret = app_request_to_launchpad(APP_TERM_BY_PID, pkgname, NULL);
+ return ret;
+}
+
+SLPAPI int aul_kill_pid(int pid)
+{
+ char pkgname[MAX_PID_STR_BUFSZ];
+ int ret;
+
+ if (pid <= 0)
+ return AUL_R_EINVAL;
+
+ snprintf(pkgname, MAX_PID_STR_BUFSZ, "%d", pid);
+ ret = app_request_to_launchpad(APP_KILL_BY_PID, pkgname, NULL);
+ return ret;
+}
+
+/* vi: set ts=8 sts=8 sw=8: */
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <glib.h>
+#include <poll.h>
+#include <bundle.h>
+#include "aul.h"
+#include "aul_api.h"
+#include "launch.h"
+#include "simple_util.h"
+
+static GSource *src;
+
+static gboolean __aul_glib_check(GSource *src);
+static gboolean __aul_glib_dispatch(GSource *src, GSourceFunc callback,
+ gpointer data);
+static gboolean __aul_glib_prepare(GSource *src, gint *timeout);
+static gboolean __app_start_internal(gpointer data);
+
+static gboolean __aul_glib_check(GSource *src)
+{
+ GSList *fd_list;
+ GPollFD *tmp;
+
+ fd_list = src->poll_fds;
+ do {
+ tmp = (GPollFD *) fd_list->data;
+ if ((tmp->revents & (POLLIN | POLLPRI)))
+ return TRUE;
+ fd_list = fd_list->next;
+ } while (fd_list);
+
+ return FALSE;
+}
+
+static gboolean __aul_glib_dispatch(GSource *src, GSourceFunc callback,
+ gpointer data)
+{
+ callback(data);
+ return TRUE;
+}
+
+static gboolean __aul_glib_prepare(GSource *src, gint *timeout)
+{
+ return FALSE;
+}
+
+GSourceFuncs funcs = {
+ .prepare = __aul_glib_prepare,
+ .check = __aul_glib_check,
+ .dispatch = __aul_glib_dispatch,
+ .finalize = NULL
+};
+
+gboolean __aul_glib_handler(gpointer data)
+{
+ GPollFD *gpollfd = (GPollFD *) data;
+ aul_sock_handler(gpollfd->fd);
+ return TRUE;
+}
+
+static gboolean __app_start_internal(gpointer data)
+{
+ bundle *kb;
+
+ kb = (bundle *) data;
+ app_start(kb);
+ bundle_free(kb);
+
+ return 0;
+}
+
+SLPAPI int aul_launch_init(
+ int (*aul_handler) (aul_type type, bundle *, void *), void *data)
+{
+ int fd;
+ GPollFD *gpollfd;
+ int ret;
+
+ if (aul_handler != NULL)
+ aul_register_init_callback(aul_handler, data);
+
+ fd = aul_initialize();
+ if (fd < 0)
+ return fd;
+
+ src = g_source_new(&funcs, sizeof(GSource));
+
+ gpollfd = (GPollFD *) g_malloc(sizeof(GPollFD));
+ gpollfd->events = POLLIN;
+ gpollfd->fd = fd;
+
+ g_source_add_poll(src, gpollfd);
+ g_source_set_callback(src, (GSourceFunc) __aul_glib_handler,
+ (gpointer) gpollfd, NULL);
+ g_source_set_priority(src, G_PRIORITY_DEFAULT);
+
+ ret = g_source_attach(src, NULL);
+ if (ret == 0)
+ return AUL_R_ERROR;
+
+ g_source_unref(src);
+
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_launch_fini()
+{
+ g_source_destroy(src);
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_launch_argv_handler(int argc, char **argv)
+{
+ bundle *b;
+
+ if (!aul_is_initialized())
+ return AUL_R_ENOINIT;
+
+ b = bundle_import_from_argv(argc, argv);
+ if (b == NULL) {
+ _E("bundle for APP_START is NULL");
+ }
+ if (g_idle_add(__app_start_internal, b) > 0)
+ return AUL_R_OK;
+ else
+ return AUL_R_ERROR;
+}
+
+SLPAPI int aul_launch_local(bundle *b)
+{
+ if (!aul_is_initialized())
+ return AUL_R_ENOINIT;
+
+ if (b == NULL) {
+ _E("bundle for APP_START is NULL");
+ }
+ if (g_idle_add(__app_start_internal, b) > 0)
+ return AUL_R_OK;
+ else
+ return AUL_R_ERROR;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "aul.h"
+#include "aul_api.h"
+#include "app_sock.h"
+#include "simple_util.h"
+#include "launch.h"
+#include "aul_util.h"
+
+/*#define ACTIVATE_PREEMPT_FEATURE*/
+
+typedef struct _app_resultcb_info_t {
+ int launched_pid;
+ void (*cb_func) (bundle *kb, int is_cancel, void *data);
+ void *priv_data;
+ struct _app_resultcb_info_t *next;
+} app_resultcb_info_t;
+
+static int latest_caller_pid = -1;
+static app_resultcb_info_t *rescb_head = NULL;
+
+static void __add_resultcb(int pid, void (*cbfunc) (bundle *, int, void *),
+ void *data);
+static app_resultcb_info_t *__find_resultcb(int pid);
+static void __remove_resultcb(app_resultcb_info_t *info);
+static int __call_app_result_callback(bundle *kb, int is_cancel,
+ int launched_pid);
+static int __get_caller_pid(bundle *kb);
+
+
+
+static void __add_resultcb(int pid, void (*cbfunc) (bundle *, int, void *),
+ void *data)
+{
+ app_resultcb_info_t *info;
+
+ info = (app_resultcb_info_t *) malloc(sizeof(app_resultcb_info_t));
+ if(info == NULL)
+ return;
+ info->launched_pid = pid;
+ info->cb_func = cbfunc;
+ info->priv_data = data;
+
+ info->next = rescb_head;
+ rescb_head = info;
+}
+
+static app_resultcb_info_t *__find_resultcb(int pid)
+{
+ app_resultcb_info_t *tmp;
+
+ tmp = rescb_head;
+ while (tmp) {
+ if (tmp->launched_pid == pid)
+ return tmp;
+ tmp = tmp->next;
+ }
+ return NULL;
+}
+
+static void __remove_resultcb(app_resultcb_info_t *info)
+{
+ app_resultcb_info_t *tmp;
+
+ if (rescb_head == NULL || info == NULL)
+ return;
+
+ if (rescb_head == info) {
+ rescb_head = info->next;
+ free(info);
+ return;
+ }
+
+ tmp = rescb_head;
+ while (tmp) {
+ if (tmp->next == info) {
+ tmp->next = info->next;
+ free(info);
+ return;
+ }
+ tmp = tmp->next;
+ }
+}
+
+/**
+ * call result callback function
+ * run in caller
+ */
+static int __call_app_result_callback(bundle *kb, int is_cancel,
+ int launched_pid)
+{
+ app_resultcb_info_t *info;
+ int pgid;
+ char *fwdpid_str;
+
+ if (((info = __find_resultcb(launched_pid)) == NULL)
+ || (launched_pid < 0)) {
+ _E("reject by pid - wait pid = %d, recvd pid = %d\n", getpid(),
+ launched_pid);
+
+ /* second chance - support app launched by shell script*/
+ pgid = getpgid(launched_pid);
+ if (pgid <= 1)
+ return -1;
+ if ((info = __find_resultcb(pgid)) == NULL) {
+ _E("second chance : also reject pgid - %d\n", pgid);
+ return -1;
+ }
+ }
+
+ if (info->cb_func == NULL || kb == NULL)
+ return -1;
+
+ /* In case of aul_forward_app, update the callback data */
+ if(is_cancel == 1 &&
+ (fwdpid_str = (char *)bundle_get_val(kb, AUL_K_FWD_CALLEE_PID)))
+ {
+ app_resultcb_info_t newinfo;
+ newinfo.launched_pid = atoi(fwdpid_str);
+ newinfo.cb_func = info->cb_func;
+ newinfo.priv_data = info->priv_data;
+
+ __remove_resultcb(info);
+ __add_resultcb(newinfo.launched_pid, newinfo.cb_func, newinfo.priv_data);
+
+ _D("change callback - %s\n",AUL_K_FWD_CALLEE_PID);
+
+ goto end;
+ }
+
+ info->cb_func(kb, is_cancel, info->priv_data);
+ __remove_resultcb(info);
+
+end:
+ return 0;
+}
+
+static int __get_caller_pid(bundle *kb)
+{
+ const char *pid_str;
+ int pid;
+
+ pid_str = bundle_get_val(kb, AUL_K_ORG_CALLER_PID);
+ if(pid_str)
+ goto end;
+
+ pid_str = bundle_get_val(kb, AUL_K_CALLER_PID);
+ if (pid_str == NULL)
+ return -1;
+
+end:
+ pid = atoi(pid_str);
+ if (pid <= 1)
+ return -1;
+
+ return pid;
+}
+
+#ifdef ACTIVATE_PREEMPT_FEATURE
+static int __send_to_cancel(int pid)
+{
+ /* Say "Your result request is cancel!" to caller */
+ bundle *kb;
+ int ret;
+ char tmp_pid[MAX_PID_STR_BUFSZ];
+
+ kb = bundle_create();
+ if (kb == NULL)
+ return AUL_R_ERROR;
+ bundle_add(kb, AUL_K_SEND_RESULT, "1");
+
+ snprintf(tmp_pid, MAX_PID_STR_BUFSZ, "%d", pid);
+ bundle_add(kb, AUL_K_CALLER_PID, tmp_pid);
+
+ ret = app_send_cmd(LAUNCHPAD_PID, APP_CANCEL, kb);
+
+ bundle_free(kb);
+ return ret;
+}
+#else
+static int __send_to_cancel(int pid)
+{
+ return 0;
+}
+#endif
+
+int _app_start_res_prepare(bundle *kb)
+{
+ int pid;
+
+ if (bundle_get_val(kb, AUL_K_WAIT_RESULT) == NULL)
+ return 0;
+
+ if ((pid = __get_caller_pid(kb)) < 0) {
+ _E("caller pid is not valid");
+ return -1;
+ }
+ /* If previous caller is still waiting result,
+ send cancel packet to the caller. */
+ if (latest_caller_pid != -1)
+ __send_to_cancel(latest_caller_pid);
+
+ latest_caller_pid = pid;
+ _D("result msg prepare done");
+
+ return 0;
+}
+
+int app_result(int cmd, bundle *kb, int launched_pid)
+{
+ switch (cmd) {
+ case APP_RESULT:
+ __call_app_result_callback(kb, 0, launched_pid);
+ break;
+ case APP_CANCEL:
+ __call_app_result_callback(kb, 1, launched_pid);
+ break;
+ }
+
+ return 0;
+}
+
+SLPAPI int aul_launch_app_with_result(const char *pkgname, bundle *kb,
+ void (*cbfunc) (bundle *, int, void *),
+ void *data)
+{
+ int ret;
+
+ if (!aul_is_initialized()) {
+ if (aul_launch_init(NULL, NULL) < 0)
+ return AUL_R_ENOINIT;
+ }
+
+ if (pkgname == NULL || cbfunc == NULL || kb == NULL)
+ return AUL_R_EINVAL;
+
+ ret = app_request_to_launchpad(APP_START_RES, pkgname, kb);
+
+ if (ret > 0)
+ __add_resultcb(ret, cbfunc, data);
+
+ return ret;
+}
+
+void __iterate(const char *key, const char *val, void *data)
+{
+ static int i=0;
+ _D("%d %s %s", i++, key, val);
+}
+
+SLPAPI int aul_forward_app(const char* pkgname, bundle *kb)
+{
+ char *caller;
+ int ret;
+ bundle *dupb;
+ bundle *outb;
+ char tmp_pid[MAX_PID_STR_BUFSZ];
+
+ if(pkgname == NULL || kb == NULL)
+ return AUL_R_EINVAL;
+
+ caller = (char *)bundle_get_val(kb, AUL_K_CALLER_PID);
+ if(caller == NULL) {
+ _E("original msg doest not have caller pid");
+ return AUL_R_EINVAL;
+ }
+
+ bundle_del(kb, AUL_K_ORG_CALLER_PID);
+ bundle_add(kb, AUL_K_ORG_CALLER_PID, caller);
+
+ dupb = bundle_dup(kb);
+ if(dupb == NULL) {
+ _E("bundle duplicate fail");
+ return AUL_R_EINVAL;
+ }
+
+ if(bundle_get_val(kb, AUL_K_WAIT_RESULT) != NULL) {
+ ret = app_request_to_launchpad(APP_START_RES, pkgname, kb);
+ if(ret < 0)
+ goto end;
+ } else {
+ ret = app_request_to_launchpad(APP_START, pkgname, kb);
+ goto end;
+ }
+
+// bundle_iterate(dupb, __iterate, NULL);
+
+ snprintf(tmp_pid, MAX_PID_STR_BUFSZ,"%d",ret);
+
+ ret = aul_create_result_bundle(dupb, &outb);
+ if(ret < 0)
+ return ret;
+
+ bundle_del(outb, AUL_K_FWD_CALLEE_PID);
+ bundle_add(outb, AUL_K_FWD_CALLEE_PID, tmp_pid);
+
+// bundle_iterate(outb, __iterate, NULL);
+
+ ret = aul_send_result(outb, 1);
+
+ bundle_free(outb);
+end:
+ bundle_free(dupb);
+
+ return ret;
+}
+
+
+SLPAPI int aul_create_result_bundle(bundle *inb, bundle **outb)
+{
+ const char *pid_str;
+
+ *outb = NULL;
+
+ if(inb == NULL){
+ _E("return msg create fail");
+ return AUL_R_EINVAL;
+ }
+
+ *outb = bundle_create();
+ if (*outb == NULL) {
+ _E("return msg create fail");
+ return AUL_R_ERROR;
+ }
+
+ if(bundle_get_val(inb, AUL_K_WAIT_RESULT) != NULL) {
+ bundle_add(*outb, AUL_K_SEND_RESULT, "1");
+ _D("original msg is msg with result");
+ } else {
+ _D("original msg is not msg with result");
+ }
+
+
+ pid_str = bundle_get_val(inb, AUL_K_ORG_CALLER_PID);
+ if(pid_str) {
+ bundle_add(*outb, AUL_K_ORG_CALLER_PID, pid_str);
+ goto end;
+ }
+
+ pid_str = bundle_get_val(inb, AUL_K_CALLER_PID);
+ if (pid_str == NULL) {
+ _E("original msg doest not have caller pid");
+ bundle_free(*outb);
+ *outb = NULL;
+ return AUL_R_EINVAL;
+ }
+ bundle_add(*outb, AUL_K_CALLER_PID, pid_str);
+
+end:
+ return AUL_R_OK;
+}
+
+int aul_send_result(bundle *kb, int is_cancel)
+{
+ int pid;
+ int ret;
+
+ if ((pid = __get_caller_pid(kb)) < 0)
+ return AUL_R_EINVAL;
+
+ if (bundle_get_val(kb, AUL_K_SEND_RESULT) == NULL)
+ {
+ _D("original msg is not msg with result");
+ return AUL_R_OK;
+ }
+
+ ret = app_send_cmd(AUL_UTIL_PID, (is_cancel==1)? APP_CANCEL : APP_RESULT, kb);
+
+ if(latest_caller_pid == pid)
+ latest_caller_pid = -1;
+
+ return ret;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "mida.h"
+#include "menu_db_util.h"
+#include "simple_util.h"
+
+#define MIDA_DB_PATH "/opt/dbspace/.mida.db"
+#define QUERY_MAXLEN 4096
+#define BUF_MAX_LEN 1024
+
+#define MIDA_TBL_NAME "mida"
+#define MIDA_F_PKGNAME "pkg_name"
+#define MIDA_F_MIMETYPE "mime_type"
+
+#define SVC_TBL_NAME "svc"
+#define SVC_F_PKGNAME "pkg_name"
+#define SVC_F_SVCNAME "svc_name"
+
+#define SYSSVC_TBL_NAME "system_svc"
+#define SYSSVC_F_SVCNAME "svc_name"
+
+static sqlite3 *mida_db = NULL;
+
+
+static int _exec(sqlite3 *db, char *query);
+static int _init(void);
+static int __fini(void);
+static int __delete_all(const char *tbl_name);
+static int __delete_with_field(const char *tbl_name, const char *f_name,
+ const char *val, int equal);
+static int __count_with_field(const char *tbl_name, const char *f_name,
+ const char *val, int equal);
+static char *__get_with_field(const char *tbl_name, const char *get_f_name,
+ const char *f_name, const char *val, int equal);
+static int __doubt_sql_injection(const char *str);
+
+
+
+/**
+ * exec
+ * param[in] db handler
+ * param[in] query query
+ * return This method returns 0 (SUCCESS) or -1 (FAIL)
+ */
+static int _exec(sqlite3 *db, char *query)
+{
+ int rc = 0;
+ char *errmsg = NULL;
+
+ retvm_if(db == NULL, -1, "DB handler is null");
+
+ rc = sqlite3_exec(db, query, NULL, 0, &errmsg);
+
+ if (rc != SQLITE_OK) {
+ _D("Query: [%s]", query);
+ _E("SQL error: %s\n", errmsg);
+ sqlite3_free(errmsg);
+ return (-1);
+ }
+
+ return 0;
+}
+
+/**
+ * db initialize
+ */
+static int _init(void)
+{
+ int rc;
+
+ if (mida_db) {
+ _D("Already initialized\n");
+ return 0;
+ }
+
+ rc = sqlite3_open(MIDA_DB_PATH, &mida_db);
+ if (rc) {
+ _E("Can't open database: %s", sqlite3_errmsg(mida_db));
+ goto err;
+ }
+ /* Enable persist journal mode */
+ rc = sqlite3_exec(mida_db, "PRAGMA journal_mode = PERSIST", NULL, NULL,
+ NULL);
+ if (SQLITE_OK != rc) {
+ _D("Fail to change journal mode\n");
+ goto err;
+ }
+
+ return 0;
+err:
+ sqlite3_close(mida_db);
+ return -1;
+}
+
+static int __fini(void)
+{
+ if (mida_db) {
+ sqlite3_close(mida_db);
+ mida_db = NULL;
+ }
+ return 0;
+}
+
+static int __delete_all(const char *tbl_name)
+{
+ char *_sqlbuf;
+ int rc;
+
+ _sqlbuf = sqlite3_mprintf("DELETE FROM %s;", tbl_name);
+ rc = _exec(mida_db, _sqlbuf);
+ sqlite3_free(_sqlbuf);
+
+ return rc;
+}
+
+static int __delete_with_field(const char *tbl_name, const char *f_name,
+ const char *val, int equal)
+{
+ char tmp_val[BUF_MAX_LEN];
+ char *_sqlbuf;
+ int rc;
+
+ if (equal) {
+ _sqlbuf = sqlite3_mprintf("DELETE FROM %s WHERE %s = '%s';",
+ tbl_name, f_name, val);
+ } else {
+ snprintf(tmp_val, BUF_MAX_LEN, "%%%s%%", val);
+ _sqlbuf = sqlite3_mprintf("DELETE FROM %s WHERE %s like '%s';",
+ tbl_name, f_name, tmp_val);
+ }
+
+ rc = _exec(mida_db, _sqlbuf);
+ sqlite3_free(_sqlbuf);
+
+ return rc;
+}
+
+static int __count_with_field(const char *tbl_name, const char *f_name,
+ const char *val, int equal)
+{
+ char tmp_val[BUF_MAX_LEN];
+ char *_sqlbuf;
+ int rc;
+ char **db_result = NULL;
+ char *db_err = NULL;
+ int nrows = 0;
+ int ncols = 0;
+ int cnt;
+
+ if (equal) {
+ _sqlbuf = sqlite3_mprintf(
+ "SELECT COUNT(*) FROM %s WHERE %s = '%s';",
+ tbl_name, f_name, val);
+ } else {
+ snprintf(tmp_val, BUF_MAX_LEN, "%%%s%%", val);
+ _sqlbuf = sqlite3_mprintf(
+ "SELECT COUNT(*) FROM %s WHERE %s like '%s';", tbl_name,
+ f_name, tmp_val);
+ }
+
+ rc = sqlite3_get_table(mida_db, _sqlbuf, &db_result, &nrows, &ncols,
+ &db_err);
+ if (rc == -1 || nrows == 0) {
+ _D("get count = 0 or fail");
+ sqlite3_free_table(db_result);
+ sqlite3_free(_sqlbuf);
+ return 0;
+ } else {
+ cnt = atoi(db_result[1]);
+ sqlite3_free_table(db_result);
+ sqlite3_free(_sqlbuf);
+ }
+
+ return cnt;
+}
+
+static char *__get_with_field(const char *tbl_name, const char *get_f_name,
+ const char *f_name, const char *val, int equal)
+{
+ char tmp_val[BUF_MAX_LEN];
+ char *_sqlbuf;
+ sqlite3_stmt *stmt;
+ int ret;
+ char *res = NULL;
+
+ if (equal) {
+ _sqlbuf = sqlite3_mprintf("SELECT %s FROM %s WHERE %s = ?;",
+ get_f_name, tbl_name, f_name);
+
+ } else {
+ _sqlbuf = sqlite3_mprintf("SELECT %s FROM %s WHERE %s like ?;",
+ get_f_name, tbl_name, f_name);
+ }
+ if (_sqlbuf == NULL) {
+ _D("Failed to print the SQL query\n");
+ return res;
+ }
+
+ if (sqlite3_prepare_v2(mida_db, _sqlbuf,
+ -1, &stmt, NULL) != SQLITE_OK) {
+ _D("Failed to prepare the SQL stmt\n");
+ sqlite3_free(_sqlbuf);
+ return res;
+ }
+
+ if (equal) {
+ ret = sqlite3_bind_text(stmt, 1, val, -1, SQLITE_STATIC);
+ } else {
+ snprintf(tmp_val, BUF_MAX_LEN, "%%%s%%", val);
+ ret = sqlite3_bind_text(stmt, 1, tmp_val, -1, SQLITE_STATIC);
+ }
+ if (ret != SQLITE_OK) {
+ _D("Failed to bind %s with SQL stmt\n", val);
+ goto end;
+ }
+
+ if (sqlite3_step(stmt) == SQLITE_ROW) {
+ if (sqlite3_column_text(stmt, 0)) {
+ res = strdup((char *)sqlite3_column_text(stmt, 0));
+ }
+ }
+
+end:
+ sqlite3_finalize(stmt);
+ sqlite3_free(_sqlbuf);
+ return res;
+}
+
+static int __doubt_sql_injection(const char *str)
+{
+ char *tmp;
+ char *token;
+ char *saveptr;
+
+ if (str == NULL)
+ return 1;
+
+ /* check " , ' , ; */
+ tmp = strdup(str);
+ token = strtok_r(tmp, "\"';", &saveptr);
+
+ if (token == NULL)
+ return 1;
+
+ if (strcmp(str, token) != 0)
+ return 1;
+
+ free(tmp);
+
+ return 0;
+}
+
+int mida_clear(void)
+{
+ int rc = 0;
+
+ if (_init() < 0)
+ return -1;
+ rc = __delete_all(MIDA_TBL_NAME);
+ __fini();
+
+ return rc;
+}
+
+int mida_delete_with_pkgname(const char *pkg_name)
+{
+ int rc = 0;
+
+ retvm_if(pkg_name == NULL, -1,
+ "Invalid argument: data to delete is NULL\n");
+
+ if (_init() < 0)
+ return -1;
+ rc = __delete_with_field(MIDA_TBL_NAME, MIDA_F_PKGNAME, pkg_name, 1);
+ __fini();
+
+ return rc;
+}
+
+int mida_delete_with_mimetype(const char *mime_type)
+{
+ int rc = 0;
+
+ retvm_if(mime_type == NULL, -1,
+ "Invalid argument: data to delete is NULL\n");
+
+ if (_init() < 0)
+ return -1;
+ rc = __delete_with_field(MIDA_TBL_NAME, MIDA_F_MIMETYPE, mime_type, 0);
+ __fini();
+
+ return rc;
+}
+
+int mida_add_app(const char *mime_type, const char *pkg_name)
+{
+ int rc = -1;
+ int cnt = 0;
+ char *_sqlbuf;
+
+ retvm_if(mime_type == NULL, -1, "Mime type is null\n");
+ retvm_if(pkg_name == NULL, -1, "Package name is null\n");
+
+ if (__doubt_sql_injection(mime_type))
+ return -1;
+
+ if (_init() < 0)
+ return -1;
+
+ cnt = __count_with_field(MIDA_TBL_NAME, MIDA_F_MIMETYPE, mime_type, 0);
+
+ if (cnt == 0) {
+ _D("Inserting (%s, %s)", pkg_name, mime_type);
+ /* insert */
+ _sqlbuf = sqlite3_mprintf(
+ "INSERT INTO %s (%s,%s) values (\"%s\", \"%s\");",
+ MIDA_TBL_NAME, MIDA_F_PKGNAME, MIDA_F_MIMETYPE,
+ pkg_name, mime_type);
+
+ rc = _exec(mida_db, _sqlbuf);
+ sqlite3_free(_sqlbuf);
+ } else {
+ _D("Setting %s for %s", pkg_name, mime_type);
+ /* update */
+ _sqlbuf = sqlite3_mprintf(
+ "UPDATE %s SET %s = '%s' where %s = '%s';",
+ MIDA_TBL_NAME, MIDA_F_PKGNAME, pkg_name,
+ MIDA_F_MIMETYPE, mime_type);
+
+ rc = _exec(mida_db, _sqlbuf);
+ sqlite3_free(_sqlbuf);
+ }
+
+ if (rc < 0)
+ _E("fail to insert or update\n");
+
+ __fini();
+ return rc;
+}
+
+char *mida_get_app(const char *mime_type)
+{
+ char *res = NULL;
+
+ if (mime_type == NULL)
+ return NULL;
+
+ if (__doubt_sql_injection(mime_type))
+ return NULL;
+
+ if (_init() < 0)
+ return NULL;
+ res =
+ __get_with_field(MIDA_TBL_NAME, MIDA_F_PKGNAME, MIDA_F_MIMETYPE,
+ mime_type, 0);
+ __fini();
+
+ return res;
+}
+
+int svc_clear(void)
+{
+ int rc = 0;
+
+ if (_init() < 0)
+ return -1;
+ rc = __delete_all(SVC_TBL_NAME);
+ __fini();
+
+ return rc;
+}
+
+int svc_delete_with_pkgname(const char *pkg_name)
+{
+ int rc = 0;
+
+ retvm_if(pkg_name == NULL, -1,
+ "Invalid argument: data to delete is NULL\n");
+
+ if (_init() < 0)
+ return -1;
+ rc = __delete_with_field(SVC_TBL_NAME, SVC_F_PKGNAME, pkg_name, 1);
+ __fini();
+
+ return rc;
+}
+
+int svc_delete_with_svcname(const char *svc_name)
+{
+ int rc = 0;
+
+ retvm_if(svc_name == NULL, -1,
+ "Invalid argument: data to delete is NULL\n");
+
+ if (_init() < 0)
+ return -1;
+ rc = __delete_with_field(SVC_TBL_NAME, SVC_F_SVCNAME, svc_name, 0);
+ __fini();
+
+ return rc;
+}
+
+int svc_add_app(const char *svc_name, const char *pkg_name)
+{
+ int rc = -1;
+ int cnt = 0;
+ char *_sqlbuf;
+
+ retvm_if(svc_name == NULL, -1, "Service name is null\n");
+ retvm_if(pkg_name == NULL, -1, "Package name is null\n");
+
+ if (__doubt_sql_injection(svc_name))
+ return -1;
+
+ if (_init() < 0)
+ return -1;
+
+ cnt = __count_with_field(SVC_TBL_NAME, SVC_F_SVCNAME, svc_name, 0);
+
+ if (cnt == 0) {
+ /* insert */
+ _D("Inserting (%s, %s)", pkg_name, svc_name);
+ _sqlbuf = sqlite3_mprintf(
+ "INSERT INTO %s (%s,%s) values (\"%s\", \"%s\");",
+ SVC_TBL_NAME, SVC_F_PKGNAME, SVC_F_SVCNAME, pkg_name,
+ svc_name);
+
+ rc = _exec(mida_db, _sqlbuf);
+ sqlite3_free(_sqlbuf);
+ } else {
+ /* update */
+ _D("Setting %s for %s", pkg_name, svc_name);
+ _sqlbuf = sqlite3_mprintf(
+ "UPDATE %s SET %s = '%s' where %s = '%s';",
+ SVC_TBL_NAME, SVC_F_PKGNAME, pkg_name,
+ SVC_F_SVCNAME, svc_name);
+
+ rc = _exec(mida_db, _sqlbuf);
+ sqlite3_free(_sqlbuf);
+ }
+
+ if (rc < 0)
+ _E("fail to insert or update\n");
+
+ __fini();
+ return rc;
+}
+
+char *svc_get_app(const char *svc_name)
+{
+ char *res = NULL;
+
+ if (svc_name == NULL)
+ return NULL;
+
+ if (__doubt_sql_injection(svc_name))
+ return NULL;
+
+ if (_init() < 0)
+ return NULL;
+ res =
+ __get_with_field(SVC_TBL_NAME, SVC_F_PKGNAME, SVC_F_SVCNAME,
+ svc_name, 0);
+ __fini();
+
+ return res;
+}
+
+int is_supported_svc(const char *svc_name)
+{
+ int rc = 0;
+ int cnt = 0;
+
+ retvm_if(svc_name == NULL, 0, "Service name is null\n");
+
+ if (__doubt_sql_injection(svc_name))
+ return 0;
+
+ if (_init() < 0)
+ return 0;
+
+ cnt = __count_with_field(SYSSVC_TBL_NAME,
+ SYSSVC_F_SVCNAME, svc_name, 0);
+
+ if (cnt > 0)
+ rc = 1;
+ else
+ _D("%s is not supported.", svc_name);
+
+ __fini();
+ return rc;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 "aul.h"
+#include "aul_api.h"
+#include "mida.h"
+#include "miregex.h"
+#include <stdio.h>
+#include <string.h>
+#include <xdgmime.h>
+#include <bundle.h>
+
+#include "menu_db_util.h"
+#include "simple_util.h"
+
+#define MIME_APP_SELECTOR "org.tizen.app-selector"
+
+static int __match_content_with_regex(const char *content, regex_t *regex_preg);
+static int get_defapp_from_desktop(const char *mimetype, char *defapp, int len);
+static int _aul_get_defapp_from_mime(const char *mimetype, char *unaliased,
+ char *defapp, int len_unaliased,
+ int len_defapp);
+static int __launch_with_defapp(const char *mime_type,
+ const char *mime_content);
+
+
+
+static int __match_content_with_regex(const char *content, regex_t *regex_preg)
+{
+ if (regexec(regex_preg, content, 0, NULL, 0) == 0)
+ return 1;
+ else
+ return 0;
+}
+
+SLPAPI int aul_get_mime_from_content(const char *content, char *mimetype,
+ int len)
+{
+ char *founded = NULL;
+ regex_tbl *miregex_tbl = NULL;
+
+ if (content == NULL)
+ return AUL_R_EINVAL;
+
+ if ((miregex_tbl = miregex_get_regex_table()) == NULL) {
+ _E("load miregex_table fail\n");
+ return AUL_R_ERROR;
+ }
+
+ while (miregex_tbl) {
+ if (__match_content_with_regex(content,
+ &(miregex_tbl->regex_preg))) {
+ founded = miregex_tbl->mimetype;
+ _D("content %s => mimetype %s\n", content, founded);
+ break;
+ }
+ miregex_tbl = miregex_tbl->next;
+ }
+
+ if (founded != NULL)
+ snprintf(mimetype, len, "%s", founded);
+ else {
+ /* TODO : should to try to extract from share mime info's data*/
+ return AUL_R_ERROR;
+ }
+
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_get_mime_description(const char *mimetype, char *desc, int len)
+{
+ regex_tbl *miregex_tbl = NULL;
+ char *founded = NULL;
+
+ if (mimetype == NULL)
+ return AUL_R_EINVAL;
+
+ if ((miregex_tbl = miregex_get_regex_table()) == NULL) {
+ _E("load miregex_table fail\n");
+ return AUL_R_ERROR;
+ }
+
+ while (miregex_tbl) {
+ if (strcmp(miregex_tbl->mimetype, mimetype) == 0) {
+ founded = miregex_tbl->desc;
+ _D("mimetype %s => desc %s\n", mimetype, founded);
+ break;
+ }
+ miregex_tbl = miregex_tbl->next;
+ }
+
+ if (founded != NULL)
+ snprintf(desc, len, "%s", founded);
+ else {
+ /* TODO : should to try to extract from
+ share mime info's comment */
+ return AUL_R_ERROR;
+ }
+
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_get_mime_extension(const char *mimetype, char *ext, int len)
+{
+ const char **extlist;
+ int totlen = 0;
+ const char *unaliased_mimetype;
+
+ if (mimetype == NULL || ext == NULL || len <= 0)
+ return AUL_R_EINVAL;
+
+ unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
+ if (unaliased_mimetype == NULL)
+ return AUL_R_ERROR;
+
+ extlist = xdg_mime_get_file_names_from_mime_type(unaliased_mimetype);
+ if (extlist == NULL)
+ return AUL_R_ERROR;
+
+ if (extlist[0] == NULL)
+ return AUL_R_ERROR;
+
+ ext[0] = 0;
+ while (*extlist != NULL) {
+ if (*(extlist + 1) == NULL) {
+ snprintf(&ext[totlen], len - totlen, "%s", *extlist);
+ break;
+ } else {
+ snprintf(&ext[totlen], len - totlen, "%s,", *extlist);
+ if (strlen(*extlist) > len - totlen - 1)
+ break;
+ totlen += strlen(*extlist) + 1;
+ extlist++;
+ }
+ }
+
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_get_mime_icon(const char *mimetype, char *iconname, int len)
+{
+ const char *icon;
+ const char *unaliased_mimetype;
+
+ if (mimetype == NULL || iconname == NULL || len <= 0)
+ return AUL_R_EINVAL;
+
+ unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
+ if (unaliased_mimetype == NULL)
+ return AUL_R_ERROR;
+
+ icon = xdg_mime_get_icon(unaliased_mimetype);
+ if (icon == NULL)
+ icon = xdg_mime_get_generic_icon(unaliased_mimetype);
+
+ if (icon != NULL) {
+ snprintf(iconname, len, "%s", icon);
+ return AUL_R_OK;
+ } else
+ return AUL_R_ERROR;
+}
+
+SLPAPI int aul_get_mime_from_file(const char *filename, char *mimetype, int len)
+{
+ const char *mime;
+ if (filename == NULL)
+ return AUL_R_EINVAL;
+
+ if (access(filename, F_OK) != 0)
+ return AUL_R_EINVAL;
+
+ mime = xdg_mime_get_mime_type_for_file(filename, 0);
+ if (strcmp(mime, "application/octet-stream") == 0) {
+ mime = xdg_mime_get_mime_type_from_file_name(filename);
+ }
+
+ snprintf(mimetype, len, "%s", mime);
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_set_defapp_with_mime(const char *mimetype, const char *defapp)
+{
+ const char *unaliased_mimetype;
+
+ if (mimetype == NULL || defapp == NULL) {
+ _E("invalid arg");
+ return AUL_R_EINVAL;
+ }
+
+ unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
+ if (unaliased_mimetype == NULL)
+ return AUL_R_ERROR;
+
+ if (mida_add_app(unaliased_mimetype, defapp) < 0) {
+ _E("fail to add: mimtype-%s and defapp-%s", unaliased_mimetype,
+ defapp);
+ return AUL_R_ERROR;
+ }
+
+ return AUL_R_OK;
+}
+
+static ail_cb_ret_e __defapp_with_mime_func(
+ const ail_appinfo_h appinfo, void *user_data)
+{
+ char **package = (char **)user_data;
+ char *str;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
+
+ _D("defapp from desktop = %s", str);
+
+ *package = strdup(str);
+
+ return AIL_CB_RET_CANCEL; /*return AIL_CB_RET_CONTINUE;*/
+}
+
+static int get_defapp_from_desktop(const char *mimetype, char *defapp, int len)
+{
+ ail_filter_h filter;
+ ail_error_e ret;
+ int pkg_count = 0;
+ char *tmp = NULL;
+
+ ret = ail_filter_new(&filter);
+ if (ret != AIL_ERROR_OK)
+ return -1;
+
+ ret = ail_filter_add_str(filter, AIL_PROP_MIMETYPE_STR, mimetype);
+ if (ret != AIL_ERROR_OK) {
+ ret = -1;
+ goto out;
+ }
+
+ ail_filter_count_appinfo(filter, &pkg_count);
+
+ if (pkg_count == 1) {
+ ail_filter_list_appinfo_foreach(filter,
+ __defapp_with_mime_func, (void *)&tmp);
+
+ if(tmp) {
+ strncpy(defapp,tmp,len);
+ _D("defapp from desktop = %s", defapp);
+ aul_set_defapp_with_mime(mimetype, defapp);
+ ret = 0;
+ free(tmp);
+ }
+ } else
+ ret = -1;
+
+out:
+ ail_filter_destroy(filter);
+ return ret;
+}
+
+SLPAPI int aul_get_defapp_from_mime(const char *mimetype, char *defapp, int len)
+{
+ char *res;
+ const char *unaliased_mimetype;
+
+ if (mimetype == NULL || defapp == NULL || len <= 0)
+ return AUL_R_EINVAL;
+
+ unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
+ if (unaliased_mimetype == NULL)
+ return AUL_R_ERROR;
+
+ /* search mida db*/
+ if ((res = mida_get_app(unaliased_mimetype)) != NULL) {
+ snprintf(defapp, len, "%s", res);
+ free(res);
+ _D("Found %s for %s from mime db", defapp, unaliased_mimetype);
+ return AUL_R_OK;
+ }
+
+ if (get_defapp_from_desktop(unaliased_mimetype, defapp, len) != 0)
+ return AUL_R_ERROR;
+ else
+ return AUL_R_OK;
+}
+
+static int _aul_get_defapp_from_mime(const char *mimetype, char *unaliased,
+ char *defapp, int len_unaliased,
+ int len_defapp)
+{
+ char *res;
+ const char *unaliased_mimetype;
+
+ if (mimetype == NULL || unaliased == NULL || len_unaliased <= 0
+ || defapp == NULL || len_defapp <= 0)
+ return AUL_R_EINVAL;
+
+ unaliased_mimetype = xdg_mime_unalias_mime_type(mimetype);
+ if (unaliased_mimetype == NULL)
+ return AUL_R_ERROR;
+
+ snprintf(unaliased, len_unaliased, "%s", unaliased_mimetype);
+
+ /* search mida db*/
+ if ((res = mida_get_app(unaliased_mimetype)) != NULL) {
+ snprintf(defapp, len_defapp, "%s", res);
+ free(res);
+ _D("Found %s for %s from mime db", defapp, unaliased_mimetype);
+ return AUL_R_OK;
+ }
+
+ if (get_defapp_from_desktop(unaliased_mimetype, defapp, len_defapp) < 0)
+ return AUL_R_ERROR;
+ else
+ return AUL_R_OK;
+}
+
+static int __launch_with_defapp(const char *mime_type, const char *mime_content)
+{
+ ail_appinfo_h handle;
+ ail_error_e ail_ret;
+ char defapp[MAX_LOCAL_BUFSZ];
+ char unaliased_mime_type[MAX_LOCAL_BUFSZ];
+ bundle *kb = NULL;
+ int ret = AUL_R_ERROR;
+
+ kb = bundle_create();
+ if (NULL == kb) {
+ _E("bundle creation fail");
+ return ret;
+ }
+ bundle_add(kb, AUL_K_MIME_TYPE, mime_type);
+ bundle_add(kb, AUL_K_MIME_CONTENT, mime_content);
+
+ retry:
+ if (_aul_get_defapp_from_mime
+ (mime_type, unaliased_mime_type, defapp,
+ sizeof(unaliased_mime_type), sizeof(defapp)) < 0) {
+ _D("mimetype : %s, unaliased mimetype : %s, mime_content : %s,"
+ " no default app", mime_type,
+ unaliased_mime_type, mime_content);
+ bundle_add(kb, AUL_K_UNALIASED_MIME_TYPE, unaliased_mime_type);
+ ret = aul_launch_app(MIME_APP_SELECTOR, kb);
+ /* TODO: When launching MIME APP SELECTOR, what should
+ be the return value? */
+ /* Currently, it returns 0 if the app selector is launched */
+ if (ret > 0)
+ ret = 0;
+ } else {
+ ail_ret = ail_get_appinfo(defapp, &handle);
+
+ if (ail_ret == AIL_ERROR_OK) {
+ ail_destroy_appinfo(handle);
+ _D("mimetype : %s, unaliased mimetype : %s, "
+ "mime_content : %s, defapp : %s", mime_type,
+ unaliased_mime_type,
+ mime_content, defapp);
+ bundle_add(kb, AUL_K_UNALIASED_MIME_TYPE,
+ unaliased_mime_type);
+ ret = aul_launch_app(defapp, kb);
+ } else if (ail_ret == AIL_ERROR_NO_DATA) {
+ _D("defapp %s for mimetype : %s, mime_content : %s "
+ "does NOT exist", defapp,
+ mime_type, mime_content);
+ mida_delete_with_pkgname(defapp);
+ ail_destroy_appinfo(handle);
+ goto retry;
+ } else {
+ _E("ail_get_appinfo with %s failed", defapp);
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return ret;
+ }
+ }
+ bundle_free(kb);
+ return ret;
+}
+
+SLPAPI int aul_open_content(const char *content)
+{
+ int ret;
+ char mime[MAX_LOCAL_BUFSZ];
+ if ((ret = aul_get_mime_from_content(content, mime, sizeof(mime))) < 0)
+ return ret;
+
+ return __launch_with_defapp(mime, content);
+}
+
+SLPAPI int aul_open_file_with_mimetype(const char *filename,
+ const char *mimetype)
+{
+ if (mimetype == NULL)
+ return AUL_R_EINVAL;
+
+ return __launch_with_defapp(mimetype, filename);
+}
+
+SLPAPI int aul_open_file(const char *filename)
+{
+ int ret;
+ char mime[MAX_LOCAL_BUFSZ];
+ if ((ret = aul_get_mime_from_file(filename, mime, sizeof(mime))) < 0)
+ return ret;
+
+ return __launch_with_defapp(mime, filename);
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 "miregex.h"
+#include "simple_util.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define MIREGEX_DIR SHARE_PREFIX"/miregex"
+#define ONELINE_BUF 1024
+
+typedef struct miregex_file_info_t {
+ char *regex;
+ char *desc;
+} miregex_file_info;
+
+regex_tbl *miregex_tbl = NULL;
+static time_t miregex_mtime = 0;
+
+static void __free_miregex_file_info(miregex_file_info *info);
+static miregex_file_info *__get_miregex_file_info(const char *path);
+static int __add_miregex(const char *name, const char *regex, const char *desc);
+static int __need_update_miregex_tbl();
+static void __miregex_free_regex_table();
+
+
+
+static void __free_miregex_file_info(miregex_file_info *info)
+{
+ if (info == NULL)
+ return;
+
+ if (info->regex != NULL)
+ free(info->regex);
+ if (info->desc != NULL)
+ free(info->desc);
+
+ free(info);
+}
+
+static miregex_file_info *__get_miregex_file_info(const char *path)
+{
+ FILE *f;
+ char oneline[ONELINE_BUF];
+ miregex_file_info *info;
+
+ f = fopen(path, "r");
+ if (f == NULL) {
+ _E("miregex file %s is cannot open", path);
+ return NULL;
+ }
+
+ info = (miregex_file_info *) malloc(sizeof(miregex_file_info));
+ if(info == NULL) {
+ fclose(f);
+ return NULL;
+ }
+
+ info->regex = NULL;
+ info->desc = NULL;
+
+ while ((info->regex == NULL) || (info->desc == NULL)) {
+ memset(oneline, 0, ONELINE_BUF);
+ if (fgets(oneline, ONELINE_BUF, f) == NULL)
+ break;
+
+ oneline[strlen(oneline) - 1] = 0;
+
+ if (info->regex == NULL)
+ info->regex = strdup(oneline);
+ else
+ info->desc = strdup(oneline);
+ }
+
+ /*_D("conf file process done : info->regex = %s,
+ info->desc = %s",info->regex, info->desc);*/
+ fclose(f);
+
+ return info;
+}
+
+static int __add_miregex(const char *name, const char *regex, const char *desc)
+{
+ regex_tbl *tbl = NULL;
+ int error;
+ int ret;
+ char *msg = NULL;
+
+ if (regex == NULL)
+ return -1;
+
+ tbl = (regex_tbl *) malloc(sizeof(regex_tbl));
+ if (NULL == tbl) {
+ _E("Malloc failed!");
+ return -1;
+ }
+
+ if ((error = regcomp(&(tbl->regex_preg), regex,
+ REG_EXTENDED | REG_NOSUB)) != 0) {
+ ret = regerror(error, &(tbl->regex_preg), NULL, 0);
+ msg = (char *)malloc(sizeof(char) * ret);
+ if (NULL == msg) {
+ _E("Malloc failed!");
+ if (tbl) {
+ free(tbl);
+ tbl = NULL;
+ }
+ return -1;
+ }
+ regerror(error, &(tbl->regex_preg), msg, ret);
+ _E("regex compile error - %s\n", msg);
+ if (msg) {
+ free(msg);
+ msg = NULL;
+ }
+ if (tbl) {
+ free(tbl);
+ tbl = NULL;
+ }
+ return -1;
+ }
+
+ tbl->mimetype = strdup(name);
+ tbl->regex = strdup(regex);
+ if (desc != NULL)
+ tbl->desc = strdup(desc);
+ tbl->next = miregex_tbl;
+ miregex_tbl = tbl;
+
+ /*_D("added regex - %d %s %s##",getpid(),tbl->mimetype,tbl->regex);*/
+
+ return 0;
+}
+
+static int __need_update_miregex_tbl()
+{
+ struct stat st;
+
+ if (stat(MIREGEX_DIR, &st) < 0) {
+ _E("stat error - check miregex dir - %s", MIREGEX_DIR);
+ return 1;
+ }
+
+ if (st.st_mtime != miregex_mtime) {
+ miregex_mtime = st.st_mtime;
+ return 1;
+ }
+
+ if (miregex_tbl == NULL) {
+ miregex_mtime = st.st_mtime;
+ return 1;
+ }
+
+ return 0;
+}
+
+static void __miregex_free_regex_table()
+{
+ regex_tbl *tbl;
+
+ while (miregex_tbl) {
+ if (miregex_tbl->mimetype != NULL)
+ free(miregex_tbl->mimetype);
+ if (miregex_tbl->regex != NULL)
+ free(miregex_tbl->regex);
+ if (miregex_tbl->desc != NULL)
+ free(miregex_tbl->desc);
+ regfree(&(miregex_tbl->regex_preg));
+
+ tbl = miregex_tbl;
+ miregex_tbl = miregex_tbl->next;
+ free(tbl);
+ }
+
+ miregex_tbl = NULL;
+}
+
+regex_tbl *miregex_get_regex_table()
+{
+ DIR *dp;
+ struct dirent *dentry;
+ char buf[MAX_LOCAL_BUFSZ];
+ miregex_file_info *info;
+
+ if (!__need_update_miregex_tbl())
+ return miregex_tbl;
+
+ _D("*** reload miregex tbl ***");
+
+ if (miregex_tbl != NULL)
+ __miregex_free_regex_table();
+
+ dp = opendir(MIREGEX_DIR);
+ if (dp == NULL)
+ return NULL;
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (dentry->d_name[0] == '.')
+ continue;
+
+ snprintf(buf, sizeof(buf), "%s/%s", MIREGEX_DIR,
+ dentry->d_name);
+ info = __get_miregex_file_info(buf);
+ if (info == NULL)
+ continue;
+
+ if (__add_miregex(dentry->d_name,
+ info->regex, info->desc) < 0) {
+ /* TODO : invalid regular expression - will be removed*/
+ }
+
+ __free_miregex_file_info(info);
+ }
+
+ closedir(dp);
+
+ return miregex_tbl;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "aul.h"
+#include "aul_api.h"
+#include "menu_db_util.h"
+#include "simple_util.h"
+#include "app_sock.h"
+#include "aul_util.h"
+
+typedef struct _internal_param_t {
+ aul_app_info_iter_fn enum_fn;
+ void *user_param;
+} internal_param_t;
+
+static int __get_pkgname_bypid(int pid, char *pkgname, int len);
+
+SLPAPI int aul_app_is_running(const char *appid)
+{
+ int ret = 0;
+
+ if (appid == NULL)
+ return 0;
+
+ ret = __app_send_raw(AUL_UTIL_PID, APP_IS_RUNNING, (unsigned char*)appid, strlen(appid));
+
+ if(ret > 0)
+ return true;
+
+ return 0;
+}
+
+SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
+ void *user_param)
+{
+ app_pkt_t *pkt = NULL;
+ char *saveptr1, *saveptr2;
+ char *token;
+ char *pkt_data;
+ aul_app_info info;
+
+ memset(&info, 0, sizeof(info));
+ if (enum_fn == NULL)
+ return AUL_R_EINVAL;
+
+ pkt = __app_send_cmd_with_result(AUL_UTIL_PID, APP_RUNNING_INFO);
+
+ if (pkt == NULL)
+ return AUL_R_ERROR;
+
+ for( pkt_data = (char *)pkt->data; ; pkt_data = NULL) {
+ token = strtok_r(pkt_data, ";", &saveptr1);
+ if (token == NULL)
+ break;
+ info.pid = atoi(strtok_r(token, ":", &saveptr2));
+ info.appid = strtok_r(NULL, ":", &saveptr2);
+ info.app_path = strtok_r(NULL, ":", &saveptr2);
+ info.pkg_name = strdup(info.appid);
+
+ enum_fn(&info, user_param);
+ }
+
+ free(info.pkg_name);
+ free(pkt);
+
+ return AUL_R_OK;
+}
+
+static int __get_pkgname_bypid(int pid, char *pkgname, int len)
+{
+ char *cmdline;
+ app_info_from_db *menu_info;
+
+ cmdline = __proc_get_cmdline_bypid(pid);
+ if (cmdline == NULL)
+ return -1;
+
+ if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL) {
+ free(cmdline);
+ return -1;
+ } else
+ snprintf(pkgname, len, "%s", _get_pkgname(menu_info));
+
+ free(cmdline);
+ _free_app_info_from_db(menu_info);
+
+ return 0;
+}
+
+SLPAPI int aul_app_get_pkgname_bypid(int pid, char *pkgname, int len)
+{
+ return aul_app_get_appid_bypid(pid, pkgname, len);
+}
+
+SLPAPI int aul_app_get_appid_bypid(int pid, char *appid, int len)
+{
+ int pgid;
+
+ if (appid == NULL)
+ return AUL_R_EINVAL;
+
+ if (__get_pkgname_bypid(pid, appid, len) == 0) {
+ _D("appid for %d is %s", pid, appid);
+ return AUL_R_OK;
+ }
+ /* support app launched by shell script*/
+ _D("second chance");
+ pgid = getpgid(pid);
+ if (pgid <= 1)
+ return AUL_R_ERROR;
+
+ _D("second change pgid = %d, pid = %d", pgid, pid);
+ if (__get_pkgname_bypid(pgid, appid, len) == 0)
+ return AUL_R_OK;
+
+ return AUL_R_ERROR;
+}
+
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <bundle.h>
+
+#include "aul_service.h"
+#include "aul.h"
+#include "aul_api.h"
+#include "mida.h"
+#include "menu_db_util.h"
+#include "simple_util.h"
+#include "launch.h"
+
+static int __get_defapp_from_desktop(const char *svcname,
+ char *defapp, int len);
+
+
+
+SLPAPI int aul_set_defapp_for_service(const char *svcname, const char *defapp)
+{
+ if ((svcname == NULL) || (defapp == NULL))
+ return AUL_R_EINVAL;
+
+ if (!is_supported_svc(svcname))
+ return AUL_R_EINVAL;
+
+ if (svc_add_app(svcname, defapp) < 0) {
+ _E("fail to add");
+ return AUL_R_ERROR;
+ }
+
+ return AUL_R_OK;
+}
+
+static ail_cb_ret_e __defapp_with_service_func(
+ const ail_appinfo_h appinfo, void *user_data)
+{
+ char **package = (char **)user_data;
+ char *str;
+
+ ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
+
+ _D("defapp from desktop = %s", str);
+
+ *package = strdup(str);
+
+ return AIL_CB_RET_CANCEL; /*return AIL_CB_RET_CONTINUE;*/
+}
+
+
+static int __get_defapp_from_desktop(const char *svcname, char *defapp, int len)
+{
+ char *pkgname = NULL;
+ int ret = -1;
+ ail_filter_h filter;
+ ail_error_e ail_ret;
+ int pkg_count = -1;
+
+ _D("The svcname is: %s", svcname);
+
+ ail_ret = ail_filter_new(&filter);
+ if (ail_ret != AIL_ERROR_OK)
+ return ret;
+
+ ail_ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_SERVICE_STR, svcname);
+ if (ail_ret != AIL_ERROR_OK) {
+ _E("ail_filter_add_str failed");
+ goto out;
+ }
+
+ ail_filter_count_appinfo(filter, &pkg_count);
+
+
+ /* TODO: Prioritizing inhouse app depending on the UX policy */
+ if (pkg_count == 1) {
+ ail_filter_list_appinfo_foreach(filter,
+ __defapp_with_service_func, (void *)&pkgname);
+
+ if(pkgname) {
+ strncpy(defapp,pkgname,len);
+ _D("defapp from desktop = %s", defapp);
+ aul_set_defapp_for_service(svcname, defapp);
+ ret = 0;
+ free(pkgname);
+ }
+
+ }
+
+ out:
+ if (ail_filter_destroy(filter) != AIL_ERROR_OK)
+ _E("ail_filter_destroy failed");
+ return ret;
+}
+
+SLPAPI int aul_get_defapp_for_service(const char *svcname, char *defapp,
+ int len)
+{
+ char *res = NULL;
+
+ if ((svcname == NULL) || (defapp == NULL) || len <= 0)
+ return AUL_R_EINVAL;
+
+ if (!is_supported_svc(svcname))
+ return AUL_R_EINVAL;
+
+ /* search mida db*/
+ if ((res = svc_get_app(svcname)) != NULL) {
+ snprintf(defapp, len, "%s", res);
+ free(res);
+ _D("Found %s for %s from svc db", defapp, svcname);
+ return AUL_R_OK;
+ }
+
+ if (__get_defapp_from_desktop(svcname, defapp, len) < 0)
+ return AUL_R_ERROR;
+ else
+ return AUL_R_OK;
+}
+
+SLPAPI int aul_open_service(const char *svcname, bundle *kb,
+ aul_service_res_fn cbfunc, void *userdata)
+{
+ char defapp[MAX_LOCAL_BUFSZ];
+ int must_free = 0;
+ int ret = AUL_R_ERROR;
+ ail_appinfo_h handle;
+ ail_error_e ail_ret;
+
+ if (svcname == NULL)
+ return AUL_R_EINVAL;
+
+ if (!is_supported_svc(svcname))
+ return AUL_R_EINVAL;
+
+ if (kb == NULL) {
+ kb = bundle_create();
+ must_free = 1;
+ }
+ bundle_add(kb, AUL_K_SERVICE_NAME, svcname);
+
+ retry:
+ if (aul_get_defapp_for_service(svcname, defapp, sizeof(defapp)) < 0) {
+ _D("service : %s, no default app", svcname);
+ if (must_free) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return ret;
+ } else {
+ ail_ret = ail_get_appinfo(defapp, &handle);
+
+ if (ail_ret == AIL_ERROR_OK) {
+ ail_destroy_appinfo(handle);
+ _D("svcname: %s, defapp : %s", svcname, defapp);
+
+ if (cbfunc) {
+ _D("svcname: %s, defapp : %s - with result",
+ svcname, defapp);
+ ret =
+ aul_launch_app_with_result(defapp, kb,
+ cbfunc,
+ userdata);
+ } else {
+ _D("svcname: %s, defapp : %s - no result",
+ svcname, defapp);
+ ret = aul_launch_app(defapp, kb);
+ }
+ } else if (ail_ret == AIL_ERROR_NO_DATA) {
+ _D("defapp %s for svcname: %s does NOT exist", defapp,
+ svcname);
+ svc_delete_with_pkgname(defapp);
+ ail_destroy_appinfo(handle);
+ goto retry;
+ } else {
+ _E("ail_get_appinfo with %s failed", defapp);
+ if (must_free) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return ret;
+ }
+ }
+ if (must_free)
+ bundle_free(kb);
+
+ return ret;
+
+}
+
+SLPAPI int aul_send_service_result(bundle *b)
+{
+ return aul_send_result(b, 0);
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "simple_util.h"
+
+#define BINSH_NAME "/bin/sh"
+#define BINSH_SIZE 7
+
+#define PROC_STAT_GID_POS 5
+
+
+static inline int __read_proc(const char *path, char *buf, int size);
+static inline int __find_pid_by_cmdline(const char *dname,
+ const char *cmdline, void *priv);
+static inline int __get_pgid_from_stat(int pid);
+
+
+static inline int __read_proc(const char *path, char *buf, int size)
+{
+ int fd;
+ int ret;
+
+ if (buf == NULL || path == NULL)
+ return -1;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+
+ close(fd);
+
+ return ret;
+}
+
+static inline int __find_pid_by_cmdline(const char *dname,
+ const char *cmdline, void *priv)
+{
+ char *apppath;
+ int pid = 0;
+
+ apppath = (char *)priv;
+ if (strncmp(cmdline, apppath, MAX_LOCAL_BUFSZ-1) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid))
+ pid = 0;
+ }
+
+ return pid;
+}
+
+int __proc_iter_cmdline(
+ int (*iterfunc)(const char *dname, const char *cmdline, void *priv),
+ void *priv)
+{
+ DIR *dp;
+ struct dirent *dentry;
+ int pid;
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+
+ dp = opendir("/proc");
+ if (dp == NULL) {
+ return -1;
+ }
+
+ if (iterfunc == NULL)
+ iterfunc = __find_pid_by_cmdline;
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ continue;
+
+ /* support app launched by shell script*/
+ if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
+ pid =
+ iterfunc(dentry->d_name, &buf[BINSH_SIZE + 1],
+ priv);
+ else
+ pid = iterfunc(dentry->d_name, buf, priv);
+
+ if (pid > 0) {
+ closedir(dp);
+ return pid;
+ }
+ }
+
+ closedir(dp);
+ return -1;
+}
+
+char *__proc_get_cmdline_bypid(int pid)
+{
+ char buf[MAX_LOCAL_BUFSZ];
+ int ret;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ return NULL;
+
+ /* support app launched by shell script*/
+ if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
+ return strdup(&buf[BINSH_SIZE + 1]);
+ else
+ return strdup(buf);
+}
+
+static inline int __get_pgid_from_stat(int pid)
+{
+ char buf[MAX_LOCAL_BUFSZ];
+ char *str;
+ int ret;
+ int i;
+ int count = 0;
+
+ if (pid <= 1)
+ return -1;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/stat", pid);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret < 0)
+ return -1;
+
+ for (i = 0; i < (ret - 1); i++) {
+ if (buf[i] == ' ') {
+ count++;
+ if (count == PROC_STAT_GID_POS - 1)
+ str = &(buf[i + 1]);
+ else if (count == PROC_STAT_GID_POS) {
+ buf[i] = 0;
+ break;
+ }
+ }
+ }
+
+ if (count == PROC_STAT_GID_POS)
+ pid = atoi(str);
+ else
+ pid = -1;
+
+ return pid;
+}
+
+int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv),
+ void *priv)
+{
+ DIR *dp;
+ struct dirent *dentry;
+ int _pgid;
+ int ret = -1;
+
+ dp = opendir("/proc");
+ if (dp == NULL) {
+ return -1;
+ }
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ _pgid = __get_pgid_from_stat(atoi(dentry->d_name));
+ if (pgid == _pgid) {
+ ret = iterfunc(atoi(dentry->d_name), priv);
+ if (ret >= 0)
+ break;
+ }
+ }
+
+ closedir(dp);
+ return ret;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <aul.h>
+#include <bundle.h>
+
+#include "aul_util.h"
+#include "app_sock.h"
+#include "aul_api.h"
+
+SLPAPI int aul_status_update(int status)
+{
+ int ret;
+
+ ret = __app_send_raw(AUL_UTIL_PID, APP_STATUS_UPDATE, (unsigned char *)&status, sizeof(status));
+
+ return ret;
+}
+
+SLPAPI int aul_running_list_update(char *appid, char *app_path, char *pid)
+{
+ int ret;
+ bundle *kb;
+
+ kb = bundle_create();
+
+ bundle_add(kb, AUL_K_APPID, appid);
+ bundle_add(kb, AUL_K_EXEC, app_path);
+ bundle_add(kb, AUL_K_PID, pid);
+
+ ret = app_send_cmd(AUL_UTIL_PID, APP_RUNNING_LIST_UPDATE, kb);
+
+ if (kb != NULL)
+ bundle_free(kb);
+
+ return ret;
+}
+
--- /dev/null
+# Test executables
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
+
+add_executable(aul_test
+ aul_test.c)
+target_link_libraries(aul_test aul ${pkgs_LDFLAGS})
+INSTALL(TARGETS aul_test DESTINATION bin)
+
+add_executable(launch_app
+ launch_app.c)
+target_link_libraries(launch_app aul ${pkgs_LDFLAGS})
+INSTALL(TARGETS launch_app DESTINATION bin)
+
+add_executable(dbusapp_test
+ dbusapp_test.c)
+target_link_libraries(dbusapp_test aul ${pkgs_LDFLAGS})
+
+add_executable(aul_dbus
+ aul_dbus.c)
+target_link_libraries(aul_dbus aul ${pkgs_LDFLAGS})
+
+add_executable(test_app
+ app_test.c)
+set_target_properties(test_app PROPERTIES COMPILE_FLAGS "-fpie")
+target_link_libraries(test_app "-pie" aul ${pkgs_LDFLAGS} )
+
+
+
+### Unit tests ###
+## avatar test ##
+#add_library(test_avatar STATIC EXCLUDE_FROM_ALL
+# test_avatar.c)
+#target_link_libraries(test_avatar avatar_v2_lib)
+
+## Main test function ##
+#add_executable(test_all EXCLUDE_FROM_ALL test.c)
+#target_link_libraries(test_all test_avatar)
+#set_target_properties(test_all
+# PROPERTIES SKIP_BUILD_RPATH true
+# ) # remove rpath option that is automatically generated by cmake.
+
+## 'test' target in Makefile ##
+# Run test by 'make test'
+#add_custom_target(test
+# COMMAND ./test_all
+# DEPENDS test_all
+# WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
+# COMMENT ""
+# )
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <poll.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "aul.h"
+
+/* ecore-glib integration */
+
+#include <Ecore.h>
+
+extern int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
+
+void do_create()
+{
+ /* call real create callback*/
+}
+
+void do_resume()
+{
+ /* call real resume callback*/
+ static int times = 0;
+ printf("=================================\n");
+ printf("resumed - %d\n", times++);
+ printf("=================================\n");
+}
+
+static Eina_Bool send_result(void *data)
+{
+ bundle *kb;
+ bundle *res_b;
+ kb = (bundle *) data;
+
+ aul_create_result_bundle(kb, &res_b);
+ if (res_b == NULL)
+ return 0;
+
+ aul_send_service_result(res_b);
+ bundle_free(res_b);
+
+ bundle_free(kb);
+
+ return 0;
+}
+
+static void prt_bundle(const char *key, const char *value, void *d)
+{
+ printf("bundle - key: %s, value: %s\n", key, value);
+}
+
+int do_start(void *data)
+{
+ bundle *kb = data;
+ const char *tmp;
+ struct timeval tv;
+ struct timeval cur;
+ struct timeval res;
+ static int times = 0;
+
+ printf("=================================\n");
+ printf("start callback with glib - %d\n", times++);
+ printf("=================================\n");
+
+ tmp = bundle_get_val(kb, AUL_K_STARTTIME);
+ if (tmp != NULL) {
+ sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);
+ gettimeofday(&cur, NULL);
+ timersub(&cur, &tv, &res);
+ printf("=================================\n");
+ printf("launched time = %ld sec %ld msec\n", res.tv_sec,
+ res.tv_usec / 1000);
+ printf("=================================\n");
+ }
+ bundle_del(kb, AUL_K_STARTTIME);
+
+ bundle_iterate(kb, prt_bundle, NULL);
+
+ ecore_timer_add(5, send_result, bundle_dup(kb));
+
+ return 0;
+}
+
+static int aul_handler(aul_type type, bundle *kb, void *data)
+{
+ bundle *b;
+
+ switch (type) {
+ case AUL_START:
+ b = bundle_dup(kb);
+ do_start((void *)b);
+ bundle_free(b);
+ break;
+ case AUL_RESUME:
+ do_resume();
+ break;
+ case AUL_TERMINATE:
+ exit(0);
+ break;
+ }
+ return 0;
+}
+
+int app_dead_handler(int pid, void *data)
+{
+ printf("===> %s : %d\n", __FUNCTION__, pid);
+ return 0;
+}
+
+int app_launch_handler(int pid, void *data)
+{
+ printf("===> %s : %d\n", __FUNCTION__, pid);
+ return 0;
+}
+
+__attribute__ ((visibility("default")))
+int main(int argc, char **argv)
+{
+ ecore_init();
+
+ do_create();
+
+ if (aul_launch_init(aul_handler, NULL) < 0)
+ printf("error aul_init\n");
+ if (aul_launch_argv_handler(argc, argv) < 0)
+ printf("error argv\n");
+
+ aul_listen_app_dead_signal(app_dead_handler, NULL);
+
+ aul_listen_app_launch_signal(app_launch_handler, NULL);
+
+ if (fork() == 0) {
+ printf("child test\n");
+ exit(0);
+ }
+
+ ecore_main_loop_begin();
+ return 0;
+}
+
+/* vi: set ts=8 sts=8 sw=8: */
+
+
+
+/* vi: set ts=8 sts=8 sw=8: */
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <glib.h>
+#include "aul_dbus.h"
+#include <sys/time.h>
+#include <stdlib.h>
+
+#define MAX_LOCAL_BUFSZ 128
+
+void request_cb(DBusPendingCall *pc, void *user_data)
+{
+ DBusMessage *reply;
+ DBusError error;
+ char *str;
+
+ reply = dbus_pending_call_steal_reply(pc);
+ dbus_pending_call_unref(pc);
+
+ dbus_error_init(&error);
+
+ if (!dbus_message_get_args(reply, &error,
+ DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID))
+ _E("Failed to complete call");
+
+ printf("filename = %s\n", str);
+
+ dbus_message_unref(reply);
+
+ exit(0);
+}
+
+int main(int argc, char **argv)
+{
+ DBusConnection *bus;
+ DBusError error;
+ DBusMessage *message;
+ DBusPendingCall *pc;
+ GMainLoop *loop;
+ dbus_bool_t ret;
+
+ char tmp[MAX_LOCAL_BUFSZ];
+ char *s;
+ struct timeval tv;
+
+ loop = g_main_loop_new(NULL, FALSE);
+
+ dbus_error_init(&error);
+
+ bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (bus == NULL)
+ _E("Failed to open bus to bus")
+
+ dbus_connection_setup_with_g_main(bus, NULL);
+
+ message = dbus_message_new_method_call (
+ SERVICE_NAME,PATH_NAME,INTERFACE_NAME,
+ METHOD_NAME);
+
+ gettimeofday(&tv, NULL);
+ snprintf(tmp, MAX_LOCAL_BUFSZ, "%ld/%ld", tv.tv_sec, tv.tv_usec);
+ s = tmp;
+
+ dbus_message_append_args(message,
+ DBUS_TYPE_STRING, &s, DBUS_TYPE_INVALID);
+
+ ret = dbus_connection_send_with_reply(bus, message, &pc, INT_MAX);
+ if (!ret) {
+ _E("dbus_connection_send_with_reply() failed.");
+ dbus_message_unref(message);
+ return -1;
+ }
+ if (!dbus_pending_call_set_notify(pc, request_cb, NULL, NULL))
+ _E("pending call set fail");
+
+ dbus_message_unref(message);
+
+ printf("wait result\n");
+
+ g_main_loop_run(loop);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+
+#define _E(fmt, arg...)\
+ do {\
+ printf(fmt " : %s\n", ##arg, error.message);\
+ dbus_error_free(&error);\
+ exit(1);\
+ } while (0);
+
+#define SERVICE_NAME "org.tizen.camera"
+#define PATH_NAME "/org/tizen/camera"
+#define INTERFACE_NAME SERVICE_NAME".app_result"
+#define METHOD_NAME "take_and_get"
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <poll.h>
+#include <stdio.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <Ecore.h>
+
+#include "menu_db_util.h"
+#include "aul.h"
+#define PERF_ACTIVATE
+#include "perf.h"
+
+#define MAX_LOCAL_BUFSZ 128
+#define QUERY_LEN 10240
+
+static char **gargv;
+static int gargc;
+static char *cmd;
+static int apn_pid;
+
+typedef struct _test_func_t {
+ char *name;
+ int (*func) ();
+ char *desc;
+ char *usage;
+} test_func_t;
+
+static bundle *create_internal_bundle(int start)
+{
+ bundle *kb;
+ int i;
+
+ kb = bundle_create();
+ for (i = start; i < gargc - 1; i++) {
+ if ((i + 1) > gargc - 1)
+ bundle_add(kb, gargv[i], " ");
+ else
+ bundle_add(kb, gargv[i], gargv[i + 1]);
+ }
+
+ return kb;
+}
+
+int launch_test()
+{
+ static int num = 0;
+ int ret = 0;
+ bundle *kb = NULL;
+
+ kb = create_internal_bundle(3);
+ if (NULL == kb) {
+ return -1;
+ }
+ printf("[aul_launch_app %d test] %s \n", num++, gargv[2]);
+
+ ret = aul_launch_app(gargv[2], kb);
+
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return ret;
+}
+
+int dbus_launch_test()
+{
+ bundle *kb = NULL;
+ int ret = 0;
+
+ kb = create_internal_bundle(3);
+
+ if (NULL == kb) {
+ return -1;
+ }
+
+ ret = aul_launch_app(gargv[2], kb);
+
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+
+ return ret;
+}
+
+static void prt_recvd_bundle(const char *key, const char *value, void *d)
+{
+ printf("recvd - key: %s, value: %s\n", key, value);
+}
+
+static void cb_func(bundle *kb, int is_cancel, void *data)
+{
+ int num;
+ num = (int)data;
+
+ if (is_cancel) {
+ printf("==== %d : canceled(preemptted) my request ===\n", num);
+ } else {
+ printf("==== %d : result packet ===\n", num);
+ bundle_iterate(kb, prt_recvd_bundle, NULL);
+ }
+
+ if ((strcmp(cmd, "launch_res") == 0)
+ || (strcmp(cmd, "open_svc_res") == 0))
+ ecore_main_loop_quit();
+}
+
+int open_test()
+{
+ static int num = 0;
+
+ printf("[aul_open_app %d test] %s \n", num++, gargv[2]);
+ return aul_open_app(gargv[2]);
+}
+
+int resume_test()
+{
+ static int num = 0;
+
+ printf("[aul_open_app %d test] %s \n", num++, gargv[2]);
+ return aul_resume_app(gargv[2]);
+}
+
+int resume_pid_test()
+{
+ static int num = 0;
+ printf("[aul_resume_pid %d test] %d \n", num++, apn_pid);
+ return aul_resume_pid(apn_pid);
+}
+
+int term_pid_test()
+{
+ static int num = 0;
+ printf("[aul_term_pid %d test] %d \n", num++, apn_pid);
+ return aul_terminate_pid(apn_pid);
+}
+
+static test_func_t scn_func[] = {
+ {"n", launch_test, "launch_test", ""},
+ {"n", launch_test, "launch_test", ""},
+ {"n", resume_test, "open_test", ""},
+ {"n", resume_test, "open_test", ""},
+ {"p", resume_pid_test, "resume_pid_test", ""},
+ {"p", resume_pid_test, "resume_pid_test", ""},
+ {"p", term_pid_test, "term_pid_test", ""},
+ {"n", resume_test, "open_test", ""},
+ {"n", launch_test, "launch_test", ""}
+};
+
+static Eina_Bool run_all_test(void *data)
+{
+ static int pos = 0;
+ int ret;
+
+ if (pos > sizeof(scn_func) / sizeof(test_func_t) - 1) {
+ printf("all internal test done\n");
+ ecore_main_loop_quit();
+ return 0;
+ }
+
+ if (strncmp(scn_func[pos].name, "n", 1) == 0) {
+ printf("[test %d] %s , pkgname = %s\n", pos, scn_func[pos].desc,
+ gargv[2]);
+ apn_pid = scn_func[pos].func();
+ printf("... return pid = %d\n", apn_pid);
+ } else {
+ printf("[test %d] %s , pid = %d\n", pos, scn_func[pos].desc,
+ apn_pid);
+ ret = scn_func[pos].func();
+ printf("... return res = %d\n", ret);
+ }
+ pos++;
+
+ return 1;
+}
+
+int all_test()
+{
+ ecore_timer_add(2, run_all_test, NULL);
+ return 0;
+}
+
+int is_run_test()
+{
+ if (aul_app_is_running(gargv[2]))
+ printf("... %s is running\n", gargv[2]);
+ else
+ printf("... %s is not running\n", gargv[2]);
+
+ return 0;
+}
+
+int iterfunc(const aul_app_info *info, void *data)
+{
+ printf("\t==========================\n");
+ printf("\t pkg_name: %s\n", info->appid);
+ printf("\t app_path: %s\n", info->app_path);
+ printf("\t running pid: %d\n", info->pid);
+ printf("\t==========================\n");
+
+ return 0;
+}
+
+int get_allpkg_test()
+{
+ static int num = 0;
+ printf("[aul_app_get_ruuning_app_info %d test] \n", num++);
+ return aul_app_get_running_app_info(iterfunc, NULL);
+}
+
+int get_pkgpid_test()
+{
+ int pid = 0;
+ static int num = 0;
+ char buf[MAX_LOCAL_BUFSZ];
+
+ printf("[aul_app_get_appid_bypid %d test] \n", num++);
+ pid = atoi(gargv[2]);
+
+ if (aul_app_get_appid_bypid(pid, buf, sizeof(buf)) < 0)
+ printf("no such pkg by %d\n", pid);
+ else
+ printf("pkgname = %s, pid = %d\n", buf, pid);
+
+ return 0;
+}
+
+int open_file_test()
+{
+ static int num = 0;
+ printf("[aul_open_file %d test] %s \n", num++, gargv[2]);
+ return aul_open_file(gargv[2]);
+}
+
+int open_content_test()
+{
+ static int num = 0;
+ printf("[aul_open_content %d test] %s \n", num++, gargv[2]);
+ return aul_open_content(gargv[2]);
+}
+
+int get_defapp_test()
+{
+ static int num = 0;
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+ printf("[aul_get_defapp_from_mime %d test] %s \n", num++, gargv[2]);
+ ret = aul_get_defapp_from_mime(gargv[2], buf, sizeof(buf));
+ if (ret >= 0)
+ printf("==> defapp name = %s\n", buf);
+ return ret;
+}
+
+int set_defapp_test()
+{
+ static int num = 0;
+ int ret;
+ printf("[aul_set_defapp_with_mime %d test] %s %s\n", num++, gargv[2],
+ gargv[3]);
+ ret = aul_set_defapp_with_mime(gargv[2], gargv[3]);
+ return ret;
+}
+
+int get_mime_file_test()
+{
+ static int num = 0;
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+ printf("[aul_get_mime_from_file %d test] %s \n", num++, gargv[2]);
+ ret = aul_get_mime_from_file(gargv[2], buf, sizeof(buf));
+ if (ret >= 0)
+ printf("==> mime type = %s\n", buf);
+ return ret;
+}
+
+int get_mime_content_test()
+{
+ static int num = 0;
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+ printf("[aul_get_mime_from_content %d test] %s \n", num++, gargv[2]);
+ ret = aul_get_mime_from_content(gargv[2], buf, sizeof(buf));
+ if (ret >= 0)
+ printf("==> mime type = %s\n", buf);
+ return ret;
+}
+
+int aul_get_mime_icon_test()
+{
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+ ret = aul_get_mime_icon(gargv[2], buf, sizeof(buf));
+ if (ret >= 0)
+ printf("==> mimetype %s : iconname = %s\n", gargv[2], buf);
+ return ret;
+}
+
+int aul_get_mime_description_test()
+{
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+ ret = aul_get_mime_description(gargv[2], buf, sizeof(buf));
+ if (ret >= 0)
+ printf("==> mimetype %s : description = %s\n", gargv[2], buf);
+ return ret;
+}
+
+int aul_get_mime_extension_test()
+{
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+ ret = aul_get_mime_extension(gargv[2], buf, sizeof(buf));
+ if (ret >= 0)
+ printf("==> mimetype %s : extension = %s\n", gargv[2], buf);
+ return ret;
+}
+
+static void print_menu_db_info(const app_info_from_db *info)
+{
+ if (info == NULL) {
+ printf("pkg %s no found\n", gargv[2]);
+ return;
+ }
+
+ printf("\t==========================\n");
+ printf("\t pkg_name: %s\n", info->pkg_name);
+ printf("\t app_path: %s\n", info->app_path);
+ printf("\t is_minst: %d\n", 0);
+ printf("\t==========================\n");
+}
+
+static int get_pkg_func()
+{
+ app_info_from_db *info;
+
+ info = _get_app_info_from_db_by_pkgname(gargv[2]);
+ print_menu_db_info(info);
+ if (info)
+ _free_app_info_from_db(info);
+
+ return 0;
+}
+
+static int update_running_list()
+{
+ aul_running_list_update(gargv[2], gargv[3], gargv[4]);
+
+ return 0;
+}
+
+
+/*
+static int set_pkg_func()
+{
+ char* pkgname;
+ char* apppath;
+ char* appname;
+ char query[QUERY_LEN];
+
+ pkgname = gargv[2];
+ apppath = gargv[3];
+
+ appname = strrchr(apppath,'/')+1;
+ snprintf(ai.app_icon_path, PATH_LEN, "aul_test_icon_path/%d",getpid());
+ snprintf(ai.desktop_path, PATH_LEN,
+ "aul_test_desktop_path/%d",getpid());
+
+ snprintf (query, sizeof(query), "insert into "TABLE_MENU"(\
+ pkg_name,\
+ app_path,\
+ app_name,\
+ app_icon_path,\
+ desktop_path)\
+ values ('%s', '%s', '%s', '%s', '%s')",
+ pkgname,
+ apppath,
+ appname,
+ record->app_icon_path,
+ record->desktop_path,
+ );
+
+ // TODO: record_add is not supported anymore; use AIL
+ if (record_add(ADD_ICON, &ai)){
+ printf("set pkg success\n");
+ return 0;
+ }
+ else{
+ printf("set pkg fail\n");
+ return -1;
+ }
+}
+
+static int del_pkg_func()
+{
+ app_info ai;
+
+ memset(&ai, 0, sizeof(app_info));
+ snprintf(ai.pkg_name, NAME_LEN, "%s", gargv[2]);
+
+ // TODO: record_add is not supported anymore; use AIL
+ if(record_delete(DELETE_MENU, &ai)){
+ printf("del pkg success\n");
+ return 0;
+ }
+ else {
+ printf("del pkg fail\n");
+ return -1;
+ }
+}
+*/
+
+static int test_regex()
+{
+ char *token;
+ char mime[MAX_LOCAL_BUFSZ];
+ char *saveptr;
+
+ INIT_PERF(NULL);
+
+ printf("=======================\n");
+
+ token = strtok_r(gargv[2], " \t\n,.()", &saveptr);
+ if (aul_get_mime_from_content(token, mime, sizeof(mime)) == AUL_R_OK)
+ printf("found %s %s\n", mime, token);
+
+ while (token) {
+ token = strtok_r(NULL, " \t\n,()", &saveptr);
+ if (aul_get_mime_from_content(token, mime, sizeof(mime)) ==
+ AUL_R_OK)
+ printf("found %s %s\n", mime, token);
+ }
+
+ PERF("======= parse end =====\n");
+ return 0;
+}
+
+int open_svc_test()
+{
+ static int num = 0;
+ int ret;
+
+ bundle *kb = NULL;
+ kb = create_internal_bundle(3);
+ if (kb == NULL) {
+ printf("bundle creation fail\n");
+ return -1;
+ }
+ printf("[aul_open_service %d test] %s \n", num++, gargv[2]);
+ ret = aul_open_service(gargv[2], kb, NULL, NULL);
+ if (ret >= 0) {
+ printf("open service success\n");
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return 0;
+ } else {
+ printf("open service fail\n");
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return -1;
+ }
+}
+
+int open_svc_res_test()
+{
+ static int num = 0;
+ int ret;
+
+ bundle *kb = NULL;
+ kb = create_internal_bundle(3);
+ if (kb == NULL) { /* Prevent Fix: ID: 21027,21581 */
+ printf("bundle creation fail\n");
+ return -1;
+ }
+
+ printf("[aul_open_service(wait result) %d test] %s \n", num++,
+ gargv[2]);
+ ret = aul_open_service(gargv[2], kb, cb_func, (void *)num);
+ if (ret >= 0) {
+ printf("open service(wait result) success\n");
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return 0;
+ } else {
+ printf("open service(wait result) fail\n");
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ return -1;
+ }
+}
+
+int get_defapp_svc_test()
+{
+ static int num = 0;
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+ printf("[aul_get_defapp_from_svc %d test] %s \n", num++, gargv[2]);
+ ret = aul_get_defapp_for_service(gargv[2], buf, sizeof(buf));
+ if (ret >= 0)
+ printf("==> defapp name = %s\n", buf);
+ return ret;
+}
+
+int set_defapp_svc_test()
+{
+ static int num = 0;
+ int ret;
+ printf("[aul_set_defapp_with_svc %d test] %s %s\n", num++, gargv[2],
+ gargv[3]);
+ ret = aul_set_defapp_for_service(gargv[2], gargv[3]);
+ return ret;
+}
+
+static test_func_t test_func[] = {
+ {"launch",launch_test,"aul_launch_app test",
+ "[usage] launch <pkgname> <key1> <val1> <key2> <val2> ..."},
+ {"open",open_test,"aul_open_app test",
+ "[usage] open <pkgname>" },
+ {"resume",resume_test,"aul_resume_app test",
+ "[usage] resume <pkgname>" },
+ {"resume_pid",resume_pid_test,"aul_resume_pid test",
+ "[usage] resume_pid <pid>" },
+ {"term_pid", term_pid_test,"aul_terminate_pid test",
+ "[usage] term_pid <pid>" },
+ {"dbuslaunch", dbus_launch_test,"launch by dbus auto activation",
+ "[usage] term_pid <pid>" },
+ {"all",all_test,"test based on predefine scenario",
+ "[usage] all <pkgname>"},
+
+ {"is_run", is_run_test,"aul_is_running test",
+ "[usage] is_run <pkgname>"},
+ {"getallpkg", get_allpkg_test, "aul_app_get_running_app_info test",
+ "[usage] getallpkg all"},
+ {"getpkgpid", get_pkgpid_test, "aul_app_get_appid_bypid test",
+ "[usage] getpkgpid <pid>"},
+
+ {"open_file", open_file_test, "aul_open_file test",
+ "[usage] open_file <filename>"},
+ {"open_content", open_content_test, "aul_open_content test",
+ "[usage] open_content <content>"},
+ {"get_defapp_mime", get_defapp_test, "aul_get_defapp_from_mime test",
+ "[usage] get_defapp_mime <mime_type>"},
+ {"set_defapp_mime", set_defapp_test, "aul_set_defapp_with_mime test",
+ "[usage] set_defapp_mime <mime_type> <defapp to be set>"},
+ {"get_mime_file", get_mime_file_test, "aul_get_mime_from_file test",
+ "[usage] get_mime_file <filename>"},
+ {"get_mime_content", get_mime_content_test, "aul_get_mime_from_content",
+ "[usage] get_mime_content <content>"},
+
+ {"get_mime_icon", aul_get_mime_icon_test, "aul_get_mime_icon test",
+ "[usage] get_mime_icon <mimetype>"},
+ {"get_mime_desc", aul_get_mime_description_test, "aul_get_mime_description test",
+ "[usage] get_mime_desc <mimetype>"},
+ {"get_mime_ext", aul_get_mime_extension_test, "aul_get_mime_extension test",
+ "[usage] get_mime_ext <mimetype>"},
+
+ {"test_regex", test_regex, "regular expression parser test",
+ "[usage] test_regex <full text>"},
+
+ {"open_svc", open_svc_test, "aul_open_service test"
+ "[usage] open_svc <svcname> <key1> <val1> <key2> <val2> ..."},
+ {"open_svc_res", open_svc_res_test, "aul_open_service (wait result) test"
+ "[usage] open_svc <svcname> <key1> <val1> <key2> <val2> ..."},
+ {"set_defapp_svc", set_defapp_svc_test, "aul_set_defapp_with_svc test"
+ "[usage] set_defapp_svc <svcname> <defapp to be set>"},
+ {"get_defapp_svc", get_defapp_svc_test, "aul_get_defapp_from_svc test"
+ "[usage] get_defapp_svc <svcname>"},
+
+ {"getpkg", get_pkg_func, "get package",
+ "[usage] getpkg <pkgname>"},
+ {"update_list", update_running_list, "update running list",
+ "[usage] update_list <appid> <app_path> <pid>"},
+/*
+ {"setpkg", set_pkg_func, "set package",
+ "[usage] setpkg <pkgname> <apppath>"},
+ {"delpkg", del_pkg_func, "del package",
+ "[usage] getpkg <pkgname>"},
+*/
+};
+
+int callfunc(char *testname)
+{
+ test_func_t *tmp;
+ int res;
+ int i;
+
+ for (i = 0; i < sizeof(test_func) / sizeof(test_func_t); i++) {
+ tmp = &test_func[i];
+ if (strcmp(testname, tmp->name) == 0) {
+ res = tmp->func();
+ if (strcmp(testname, "all")) {
+ if (res < 0)
+ printf("... test failed\n");
+ else
+ printf("... test successs ret = %d\n",
+ res);
+ }
+ }
+ }
+ return 0;
+}
+
+int dead_tracker(int pid, void *data)
+{
+ printf("[DEAD] pid = %d dead\n", pid);
+ return 0;
+}
+
+void print_usage(char *progname)
+{
+ test_func_t *tmp;
+ int i;
+
+ printf("[usage] %s <cmd> ...\n", progname);
+ printf(" - available cmd list\n");
+
+ for (i = 0; i < sizeof(test_func) / sizeof(test_func_t); i++) {
+ tmp = &test_func[i];
+ printf("\t%s : %s\n", tmp->name, tmp->desc);
+ printf("\t\t%s\n", tmp->usage);
+ }
+
+ printf("[note] getpkg/setpkg/delpkg/init_defapp_mime "
+ "cmd is internal purpose\n");
+}
+
+static Eina_Bool run_func(void *data)
+{
+ callfunc(cmd);
+
+ if (strcmp(cmd, "launch_res") == 0 || strcmp(cmd, "all") == 0
+ || strcmp(cmd, "dbuslaunch") == 0
+ || strcmp(cmd, "open_svc_res") == 0)
+ return 0;
+ else
+ ecore_main_loop_quit();
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ if (argc < 3) {
+ print_usage(argv[0]);
+ exit(0);
+ }
+
+ ecore_init();
+
+ cmd = argv[1];
+ gargc = argc;
+ gargv = argv;
+ apn_pid = atoi(argv[2]);
+
+ aul_launch_init(NULL, NULL);
+
+ /*aul_listen_app_dead_signal(dead_tracker,NULL); */
+ /*aul_listen_app_dead_signal(NULL,NULL); */
+
+ ecore_idler_add(run_func, NULL);
+
+ ecore_main_loop_begin();
+
+ return 0;
+}
+
+/* vi: set ts=8 sts=8 sw=8: */
+
--- /dev/null
+[D-BUS Service]
+Name=org.tizen.camera
+Exec=/usr/bin/aul_test dbuslaunch deb.org.tizen.camera
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <glib.h>
+#include "aul_dbus.h"
+#include "aul.h"
+#include <sys/time.h>
+#include <stdlib.h>
+
+#define MAX_LOCAL_BUFSZ 128
+
+gboolean result_func(gpointer data)
+{
+ char *str;
+ DBusMessage *reply;
+ DBusConnection *bus;
+ DBusError error;
+ DBusMessage *msg;
+
+ msg = data;
+
+ dbus_error_init(&error);
+
+ bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+
+ reply = dbus_message_new_method_return(msg);
+ dbus_message_unref(msg);
+ str = "picture0.jpg";
+
+ dbus_message_append_args(reply, DBUS_TYPE_STRING,
+ &str, DBUS_TYPE_INVALID);
+
+ dbus_connection_send(bus, reply, NULL);
+ dbus_message_unref(reply);
+
+ return 0;
+}
+
+void create_take_picture_ui(DBusMessage *msg)
+{
+ /* simulate, take photo and save time is 30 sec.*/
+ g_timeout_add(5 * 1000, result_func, msg);
+}
+
+static DBusHandlerResult
+dbus_handler(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ DBusMessage *msg;
+ char *s;
+ DBusError error;
+ struct timeval tv;
+ struct timeval cur;
+ struct timeval res;
+
+ if (dbus_message_is_method_call(message, INTERFACE_NAME, METHOD_NAME)) {
+ dbus_error_init(&error);
+ msg = dbus_message_ref(message);
+ /* real draw */
+ if (dbus_message_get_args
+ (message, &error, DBUS_TYPE_STRING, &s,
+ DBUS_TYPE_INVALID)) {
+ sscanf(s, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);
+ gettimeofday(&cur, NULL);
+ timersub(&cur, &tv, &res);
+ printf("=================================\n");
+ printf("launched time = %ld sec %ld msec\n", res.tv_sec,
+ res.tv_usec / 1000);
+ printf("=================================\n");
+ }
+ create_take_picture_ui(msg);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+static int init_dbus()
+{
+ DBusConnection *bus;
+ DBusError error;
+ char rules[MAX_LOCAL_BUFSZ];
+
+ dbus_error_init(&error);
+
+ bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+ if (!bus)
+ _E("couldn't access session bus");
+
+ dbus_connection_setup_with_g_main(bus, NULL);
+
+ dbus_bus_request_name(bus, SERVICE_NAME, 0, &error);
+ if (dbus_error_is_set(&error))
+ _E("couldn't request name");
+
+ snprintf(rules, MAX_LOCAL_BUFSZ,
+ "path='%s',type='method_call',interface='%s'",
+ PATH_NAME, INTERFACE_NAME);
+ dbus_bus_add_match(bus, rules, &error);
+
+ if (!dbus_connection_add_filter(bus, dbus_handler, NULL, NULL))
+ _E("couldn't add filter");
+
+ return 0;
+}
+
+static int aul_handler(aul_type type, bundle *kb, void *data)
+{
+ const char *tmp;
+ struct timeval tv;
+ struct timeval cur;
+ struct timeval res;
+
+ switch (type) {
+ case AUL_START:
+ printf("app start & add dbus\n");
+ tmp = bundle_get_val(kb, AUL_K_STARTTIME);
+ if (tmp != NULL) {
+ sscanf(tmp, "%ld/%ld", &tv.tv_sec, &tv.tv_usec);
+ gettimeofday(&cur, NULL);
+ timersub(&cur, &tv, &res);
+ printf("=================================\n");
+ printf("launched time by aul= %ld sec %ld msec\n",
+ res.tv_sec, res.tv_usec / 1000);
+ printf("=================================\n");
+ }
+ /* DONOT draw if auto-activated by dbus */
+ init_dbus();
+ break;
+ case AUL_RESUME:
+ break;
+ case AUL_TERMINATE:
+ exit(0);
+ break;
+ }
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ GMainLoop *loop;
+
+ loop = g_main_loop_new(NULL, FALSE);
+
+ aul_launch_init(aul_handler, NULL);
+ aul_launch_argv_handler(argc, argv);
+
+ g_main_loop_run(loop);
+
+ return 0;
+}
+
--- /dev/null
+/*
+ * aul
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <Ecore.h>
+#include "aul.h"
+
+#define ROOT_UID 0
+#define TMP_FILE "/tmp/.testpkg"
+
+static char **gargv;
+static int gargc;
+
+static bundle *create_internal_bundle(int start)
+{
+ bundle *kb;
+ int i;
+ char arg[1024] = {0, };
+ char* val_array[128];
+
+ kb = bundle_create();
+ for (i = start; i < gargc - 1; i++) {
+ if ((i + 1) > gargc - 1)
+ bundle_add(kb, gargv[i], " ");
+ else {
+ int j = 1;
+ strncpy(arg, gargv[i + 1], 1023);
+ val_array[0] = strtok(arg,",");
+ while(1)
+ {
+ val_array[j] = strtok(NULL,",");
+ if(val_array[j] == NULL)
+ break;
+ j++;
+ }
+ if(j==1)
+ bundle_add(kb, gargv[i], gargv[i + 1]);
+ else if(j>1)
+ bundle_add_str_array(kb, gargv[i],
+ (const char**)val_array, j);
+ }
+ }
+
+ return kb;
+}
+
+int launch()
+{
+ bundle *kb = NULL;
+ FILE *fp;
+ int ret = -1;
+ int pid = -1;
+
+ kb = create_internal_bundle(2);
+ if (NULL == kb) {
+ printf("bundle creation fail\n");
+ return -1;
+ }
+
+ pid = aul_launch_app(gargv[1], kb);
+
+ if (kb) {
+ bundle_free(kb);
+ kb = NULL;
+ }
+ /* Write the package name to TMP_FILE*/
+ fp = fopen(TMP_FILE, "w");
+ if (fp == NULL)
+ return -1;
+ ret = fprintf(fp, "%d", pid);
+ fclose(fp);
+ if (ret < 0)
+ return -1;
+
+ return pid;
+}
+
+void print_usage(char *progname)
+{
+ printf("[usage] %s <pkgname> <key1> <val1> <key2> <val2> ...\n",
+ progname);
+}
+
+static Eina_Bool run_func(void *data)
+{
+ if (launch() > 0) {
+ printf("... successfully launched\n");
+ } else {
+ printf("... launch failed\n");
+ }
+
+ ecore_main_loop_quit();
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ if (argc < 2) {
+ print_usage(argv[0]);
+ exit(EXIT_FAILURE);
+ }
+
+ ecore_init();
+
+ gargc = argc;
+ gargv = argv;
+
+ aul_launch_init(NULL, NULL);
+
+ ecore_idler_add(run_func, NULL);
+
+ ecore_main_loop_begin();
+
+ return 0;
+}
+