Git init
authorKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:43:34 +0000 (00:43 +0900)
committerKibum Kim <kb0929.kim@samsung.com>
Fri, 6 Jan 2012 15:43:34 +0000 (00:43 +0900)
115 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0644]
TC/build.sh [new file with mode: 0755]
TC/execute.sh [new file with mode: 0755]
TC/tet_code [new file with mode: 0755]
TC/tet_scen [new file with mode: 0755]
TC/tetbuild.cfg [new file with mode: 0755]
TC/tetclean.cfg [new file with mode: 0755]
TC/tetexec.cfg [new file with mode: 0755]
TC/unit/Makefile [new file with mode: 0644]
TC/unit/pkgname.h [new file with mode: 0755]
TC/unit/tc_gen.sh [new file with mode: 0755]
TC/unit/tslist [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_app_get_pkgname_bypid_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_app_get_running_app_info_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_app_is_running_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_get_defapp_from_mime_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_get_mime_from_content_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_get_mime_from_file_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_launch_app_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_launch_argv_handler_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_launch_init_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_open_app_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_open_content_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_open_file_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_open_file_with_mimetype_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_resume_pid_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_set_defapp_with_mime_func.c [new file with mode: 0644]
TC/unit/utc_ApplicationFW_aul_terminate_pid_func.c [new file with mode: 0644]
TC/unit/utc_MODULE_API_func.c.in [new file with mode: 0644]
aul.pc.in [new file with mode: 0644]
data/aul_mime.sh [new file with mode: 0755]
data/aul_service.sh [new file with mode: 0755]
data/aul_service_test.sh [new file with mode: 0755]
data/create_default_service.sh [new file with mode: 0755]
data/mida_db.sql [new file with mode: 0644]
data/miregex/callto.uri [new file with mode: 0644]
data/miregex/contact_shortcut.uri [new file with mode: 0644]
data/miregex/email.uri [new file with mode: 0644]
data/miregex/file.uri [new file with mode: 0644]
data/miregex/http.uri [new file with mode: 0644]
data/miregex/im.uri [new file with mode: 0644]
data/miregex/location.uri [new file with mode: 0644]
data/miregex/mmsto.uri [new file with mode: 0644]
data/miregex/phonenum.uri [new file with mode: 0644]
data/miregex/sms.uri [new file with mode: 0644]
data/miregex/tel.uri [new file with mode: 0644]
data/service/README [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/dirs [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/libaul-1-dev.install.in [new file with mode: 0644]
debian/libaul-1-executable.install.in [new file with mode: 0644]
debian/libaul-1-executable.postinst [new file with mode: 0644]
debian/libaul-1.install.in [new file with mode: 0644]
debian/libaul-1.postinst [new file with mode: 0644]
debian/rules [new file with mode: 0755]
image/high-level.png [new file with mode: 0644]
image/high-level2.png [new file with mode: 0644]
image/low-level.png [new file with mode: 0644]
image/low-level2.png [new file with mode: 0644]
include/SLP_AUL_PG.h [new file with mode: 0755]
include/app_signal.h [new file with mode: 0755]
include/app_sock.h [new file with mode: 0755]
include/aul.h [new file with mode: 0755]
include/aul_api.h [new file with mode: 0755]
include/aul_service.h [new file with mode: 0755]
include/launch.h [new file with mode: 0755]
include/menu_db_util.h [new file with mode: 0755]
include/mida.h [new file with mode: 0755]
include/miregex.h [new file with mode: 0755]
include/perf.h [new file with mode: 0755]
include/pg-doxy/doxygen.conf [new file with mode: 0755]
include/pg-doxy/pg-doxy.sh [new file with mode: 0755]
include/pg-doxy/slp_doxy.css [new file with mode: 0644]
include/pg-doxy/tool/bin/doxygen [new file with mode: 0755]
include/pg-doxy/tool/bin/doxytag [new file with mode: 0755]
include/pg-doxy/tool/man/man1/doxygen.1 [new file with mode: 0644]
include/pg-doxy/tool/man/man1/doxytag.1 [new file with mode: 0644]
include/simple_util.h [new file with mode: 0755]
launchpad_run [new file with mode: 0755]
launchpad_src/access_control.h [new file with mode: 0755]
launchpad_src/config.h [new file with mode: 0755]
launchpad_src/gl.h [new file with mode: 0755]
launchpad_src/heap_dbg.h [new file with mode: 0755]
launchpad_src/launchpad.c [new file with mode: 0755]
launchpad_src/sigchild.h [new file with mode: 0755]
launchpad_src/util_x.c [new file with mode: 0755]
launchpad_src/util_x.h [new file with mode: 0755]
legacy/preload.h [new file with mode: 0755]
legacy/preload_list.txt [new file with mode: 0644]
packaging/aul.spec [new file with mode: 0644]
src/app_signal.c [new file with mode: 0755]
src/app_sock.c [new file with mode: 0755]
src/launch.c [new file with mode: 0755]
src/launch_glib.c [new file with mode: 0755]
src/launch_with_result.c [new file with mode: 0755]
src/mida.c [new file with mode: 0755]
src/mime.c [new file with mode: 0755]
src/miregex.c [new file with mode: 0755]
src/pkginfo.c [new file with mode: 0755]
src/service.c [new file with mode: 0755]
src/simple_util.c [new file with mode: 0755]
test/CMakeLists.txt [new file with mode: 0644]
test/ac_daemon.c [new file with mode: 0755]
test/app_test.c [new file with mode: 0755]
test/aul_dbus.c [new file with mode: 0755]
test/aul_dbus.h [new file with mode: 0755]
test/aul_test.c [new file with mode: 0755]
test/dbusapp_test.c [new file with mode: 0755]
test/launch_app.c [new file with mode: 0755]
test/org.tizen.camera.service [new file with mode: 0644]

diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..064881e
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,3 @@
+Jayoun Lee <airjany@samsung.com>
+Sewook Park <sewook7.park@samsung.com>
+Jaeho Lee <jaeho81.lee@samsung.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..66e30f0
--- /dev/null
@@ -0,0 +1,128 @@
+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)
+pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime app-checker)
+
+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)
+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_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("-DRW_DATA_PREFIX=\"/opt/share\"")
+
+# 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
+               )
+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.
+
+
+
+# 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(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 /opt/share )
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/mida_db.sql DESTINATION /opt/share )
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/miregex DESTINATION /opt/share )
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/service DESTINATION /opt/share )
+
+# test
+add_subdirectory(test)
+
diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
index 0000000..9c13a9b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,204 @@
+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
diff --git a/TC/build.sh b/TC/build.sh
new file mode 100755 (executable)
index 0000000..98ebeff
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+export TET_INSTALL_PATH=/scratchbox/tetware  # local tetware path
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -c -p ./
+tcc -b -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/execute.sh b/TC/execute.sh
new file mode 100755 (executable)
index 0000000..6720da0
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+export TET_INSTALL_PATH=/mnt/nfs/tetware
+export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target
+export PATH=$TET_TARGET_PATH/bin:$PATH
+export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH
+
+export TET_ROOT=$TET_TARGET_PATH
+
+export TET_SUITE_ROOT=`pwd`
+FILE_NAME_EXTENSION=`date +%s`
+
+RESULT_DIR=results
+HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html
+JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal
+
+mkdir -p $RESULT_DIR
+
+tcc -e -j $JOURNAL_RESULT -p ./
+grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
diff --git a/TC/tet_code b/TC/tet_code
new file mode 100755 (executable)
index 0000000..a2cf6c1
--- /dev/null
@@ -0,0 +1,12 @@
+# TET reserved codes
+0 "PASS"
+1 "FAIL"
+2 "UNRESOLVED"
+3 "NOTINUSE"
+4 "UNSUPPORTED"
+5 "UNTESTED"
+6 "UNINITIATED"
+7 "NORESULT"
+
+# Test suite additional codes
+33 "INSPECT"
diff --git a/TC/tet_scen b/TC/tet_scen
new file mode 100755 (executable)
index 0000000..43cbc9b
--- /dev/null
@@ -0,0 +1,7 @@
+all
+       ^TEST
+##### Scenarios for TEST #####
+
+# Test scenario
+TEST
+       :include:/unit/tslist
diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg
new file mode 100755 (executable)
index 0000000..6192c78
--- /dev/null
@@ -0,0 +1,3 @@
+TET_OUTPUT_CAPTURE=False
+TET_BUILD_TOOL=make
+TET_PASS_TC_NAME=True
diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg
new file mode 100755 (executable)
index 0000000..c66eda4
--- /dev/null
@@ -0,0 +1,2 @@
+TET_OUTPUT_CAPTURE=False
+TET_CLEAN_TOOL=make clean
diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg
new file mode 100755 (executable)
index 0000000..0d9d39a
--- /dev/null
@@ -0,0 +1 @@
+TET_OUTPUT_CAPTURE=False
diff --git a/TC/unit/Makefile b/TC/unit/Makefile
new file mode 100644 (file)
index 0000000..f16a9e1
--- /dev/null
@@ -0,0 +1,37 @@
+CC ?= gcc
+
+TARGETS = utc_ApplicationFW_aul_launch_init_func \
+         utc_ApplicationFW_aul_launch_argv_handler_func \
+         utc_ApplicationFW_aul_launch_app_func \
+         utc_ApplicationFW_aul_open_app_func \
+         utc_ApplicationFW_aul_resume_pid_func \
+         utc_ApplicationFW_aul_terminate_pid_func \
+         utc_ApplicationFW_aul_app_is_running_func \
+         utc_ApplicationFW_aul_app_get_running_app_info_func \
+         utc_ApplicationFW_aul_app_get_pkgname_bypid_func \
+         utc_ApplicationFW_aul_open_file_func \
+         utc_ApplicationFW_aul_open_file_with_mimetype_func \
+         utc_ApplicationFW_aul_open_content_func \
+         utc_ApplicationFW_aul_get_defapp_from_mime_func \
+         utc_ApplicationFW_aul_set_defapp_with_mime_func \
+         utc_ApplicationFW_aul_get_mime_from_file_func \
+         utc_ApplicationFW_aul_get_mime_from_content_func 
+
+PKGS = aul ecore 
+
+LDFLAGS = `pkg-config --libs $(PKGS)`
+LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s
+LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s
+
+CFLAGS = -I. `pkg-config --cflags $(PKGS)`
+CFLAGS += -I$(TET_ROOT)/inc/tet3
+CFLAGS += -Wall
+
+all: $(TARGETS)
+
+$(TARGETS): %: %.c
+       $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TARGETS)
diff --git a/TC/unit/pkgname.h b/TC/unit/pkgname.h
new file mode 100755 (executable)
index 0000000..750e5d8
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ *  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 MAX_LOCAL_BUFSZ        128
+
+#define EXIST_PKGNAME          "org.tizen.calculator" 
+#define NO_EXIST_PKGNAME       "empty.fault.application"
+
+#define EXIST_FILENAME         "/opt/share/preload_list.txt"
+#define NOEXIST_FILENAME       "/empty/fault/file"
+
+#define MIMETYPE               "text/html"
+#define CONTENT                        "011-0011-1122"
+
diff --git a/TC/unit/tc_gen.sh b/TC/unit/tc_gen.sh
new file mode 100755 (executable)
index 0000000..54f482d
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+TMPSTR=$0
+SCRIPT=${TMPSTR##*/}
+
+if [ $# -lt 2 ]; then
+       echo "Usage) $SCRIPT module_name api_name"
+       exit 1
+fi
+
+MODULE=$1
+API=$2
+TEMPLATE=utc_MODULE_API_func.c.in
+TESTCASE=utc_${MODULE}_${API}_func
+
+sed -e '
+       s^@API@^'"$API"'^g
+       s^@MODULE@^'"$MODULE"'^g
+       ' $TEMPLATE > $TESTCASE.c
+
+if [ ! -e "$TESTCASE.c" ]; then
+       echo "Failed"
+       exit 1
+fi
+echo "Testcase file is $TESTCASE.c"
+echo "Done"
+echo "please put \"$TESTCASE\" as Target in Makefile"
+echo "please put \"/unit/$TESTCASE\" in tslist"
diff --git a/TC/unit/tslist b/TC/unit/tslist
new file mode 100644 (file)
index 0000000..f425a55
--- /dev/null
@@ -0,0 +1,16 @@
+/unit/utc_ApplicationFW_aul_launch_init_func
+/unit/utc_ApplicationFW_aul_launch_argv_handler_func
+/unit/utc_ApplicationFW_aul_launch_app_func
+/unit/utc_ApplicationFW_aul_open_app_func
+/unit/utc_ApplicationFW_aul_resume_pid_func
+/unit/utc_ApplicationFW_aul_terminate_pid_func
+/unit/utc_ApplicationFW_aul_app_is_running_func
+/unit/utc_ApplicationFW_aul_app_get_running_app_info_func
+/unit/utc_ApplicationFW_aul_app_get_pkgname_bypid_func
+/unit/utc_ApplicationFW_aul_open_file_func
+/unit/utc_ApplicationFW_aul_open_file_with_mimetype_func
+/unit/utc_ApplicationFW_aul_open_content_func
+/unit/utc_ApplicationFW_aul_get_defapp_from_mime_func
+/unit/utc_ApplicationFW_aul_set_defapp_with_mime_func
+/unit/utc_ApplicationFW_aul_get_mime_from_file_func
+/unit/utc_ApplicationFW_aul_get_mime_from_content_func
diff --git a/TC/unit/utc_ApplicationFW_aul_app_get_pkgname_bypid_func.c b/TC/unit/utc_ApplicationFW_aul_app_get_pkgname_bypid_func.c
new file mode 100644 (file)
index 0000000..2b9f224
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_app_get_pkgname_bypid_func_01(void);
+static void utc_ApplicationFW_aul_app_get_pkgname_bypid_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_app_get_pkgname_bypid_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_app_get_pkgname_bypid_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_app_get_pkgname_bypid()
+ */
+static void utc_ApplicationFW_aul_app_get_pkgname_bypid_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       pid = aul_launch_app(EXIST_PKGNAME,NULL);
+       sleep(1);
+       r = aul_app_get_pkgname_bypid(pid,buf,256);
+
+       if (r<0) {
+               tet_infoline("aul_app_get_pkgname_bypid() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       aul_terminate_pid(pid);
+       sleep(2);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_app_get_pkgname_bypid()
+ */
+static void utc_ApplicationFW_aul_app_get_pkgname_bypid_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = aul_app_get_pkgname_bypid(-1,buf,256);
+
+       if (r>=0) {
+               tet_infoline("aul_app_get_pkgname_bypid() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_app_get_running_app_info_func.c b/TC/unit/utc_ApplicationFW_aul_app_get_running_app_info_func.c
new file mode 100644 (file)
index 0000000..4009483
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ *  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 <tet_api.h>
+#include "aul.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_app_get_running_app_info_func_01(void);
+static void utc_ApplicationFW_aul_app_get_running_app_info_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_app_get_running_app_info_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_app_get_running_app_info_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+static int iterfunc(const aul_app_info* info, void* data)
+{
+       return 0;
+}
+
+/**
+ * @brief Positive test case of aul_app_get_running_app_info()
+ */
+static void utc_ApplicationFW_aul_app_get_running_app_info_func_01(void)
+{
+       int r = 0;
+
+       r = aul_app_get_running_app_info(iterfunc, NULL);
+
+       if (r<0) {
+               tet_infoline("aul_app_get_running_app_info() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_app_get_running_app_info()
+ */
+static void utc_ApplicationFW_aul_app_get_running_app_info_func_02(void)
+{
+       int r = 0;
+
+       r = aul_app_get_running_app_info(NULL,NULL);
+
+       if (r>=0) {
+               tet_infoline("aul_app_get_running_app_info() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_app_is_running_func.c b/TC/unit/utc_ApplicationFW_aul_app_is_running_func.c
new file mode 100644 (file)
index 0000000..c2a39bb
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_app_is_running_func_01(void);
+static void utc_ApplicationFW_aul_app_is_running_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_app_is_running_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_app_is_running_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_app_is_running()
+ */
+static void utc_ApplicationFW_aul_app_is_running_func_01(void)
+{
+       int r = 0;
+
+       pid = aul_launch_app(EXIST_PKGNAME,NULL);
+       sleep(1);
+       r = aul_app_is_running(EXIST_PKGNAME);
+
+       if (r<1) {
+               tet_infoline("aul_app_is_running() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       aul_terminate_pid(pid);
+       
+       tet_result(TET_PASS);
+       sleep(2);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_app_is_running()
+ */
+static void utc_ApplicationFW_aul_app_is_running_func_02(void)
+{
+       int r = 0;
+
+       r = aul_app_is_running(NO_EXIST_PKGNAME);
+
+       if (r==1) {
+               tet_infoline("aul_app_is_running() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_get_defapp_from_mime_func.c b/TC/unit/utc_ApplicationFW_aul_get_defapp_from_mime_func.c
new file mode 100644 (file)
index 0000000..f4d43a0
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_get_defapp_from_mime_func_01(void);
+static void utc_ApplicationFW_aul_get_defapp_from_mime_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_get_defapp_from_mime_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_get_defapp_from_mime_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_get_defapp_from_mime()
+ */
+static void utc_ApplicationFW_aul_get_defapp_from_mime_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       r = aul_get_defapp_from_mime(MIMETYPE,buf,sizeof(buf));
+
+       if (r<0) {
+               tet_infoline("aul_get_defapp_from_mime() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_get_defapp_from_mime()
+ */
+static void utc_ApplicationFW_aul_get_defapp_from_mime_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = aul_get_defapp_from_mime(NULL,buf,sizeof(buf));
+
+       if (r>=0) {
+               tet_infoline("aul_get_defapp_from_mime() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_get_mime_from_content_func.c b/TC/unit/utc_ApplicationFW_aul_get_mime_from_content_func.c
new file mode 100644 (file)
index 0000000..5da9ef9
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_get_mime_from_content_func_01(void);
+static void utc_ApplicationFW_aul_get_mime_from_content_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_get_mime_from_content_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_get_mime_from_content_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_get_mime_from_content()
+ */
+static void utc_ApplicationFW_aul_get_mime_from_content_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       r = aul_get_mime_from_content(CONTENT,buf,sizeof(buf));
+
+       if (r<0) {
+               tet_infoline("aul_get_mime_from_content() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_get_mime_from_content()
+ */
+static void utc_ApplicationFW_aul_get_mime_from_content_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = aul_get_mime_from_content(NULL,buf,sizeof(buf));
+
+       if (r>=0) {
+               tet_infoline("aul_get_mime_from_content() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_get_mime_from_file_func.c b/TC/unit/utc_ApplicationFW_aul_get_mime_from_file_func.c
new file mode 100644 (file)
index 0000000..6888511
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_get_mime_from_file_func_01(void);
+static void utc_ApplicationFW_aul_get_mime_from_file_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_get_mime_from_file_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_get_mime_from_file_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_get_mime_from_file()
+ */
+static void utc_ApplicationFW_aul_get_mime_from_file_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       r = aul_get_mime_from_file(EXIST_FILENAME,buf,sizeof(buf));
+
+       if (r<0) {
+               tet_infoline("aul_get_mime_from_file() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_get_mime_from_file()
+ */
+static void utc_ApplicationFW_aul_get_mime_from_file_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = aul_get_mime_from_file(NOEXIST_FILENAME,buf,sizeof(buf));
+
+       if (r>=0) {
+               tet_infoline("aul_get_mime_from_file() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_launch_app_func.c b/TC/unit/utc_ApplicationFW_aul_launch_app_func.c
new file mode 100644 (file)
index 0000000..1fea023
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_launch_app_func_01(void);
+static void utc_ApplicationFW_aul_launch_app_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_launch_app_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_launch_app_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_launch_app()
+ */
+static void utc_ApplicationFW_aul_launch_app_func_01(void)
+{
+       int r = 0;
+
+       r = aul_launch_app(EXIST_PKGNAME,NULL);
+
+       if (r<0) {
+               tet_infoline("aul_launch_app() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       aul_terminate_pid(r);
+       sleep(2);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_launch_app()
+ */
+static void utc_ApplicationFW_aul_launch_app_func_02(void)
+{
+       int r = 0;
+
+       r = aul_launch_app(NO_EXIST_PKGNAME,NULL);
+
+       if (r>=0) {
+               tet_infoline("aul_launch_app() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_launch_argv_handler_func.c b/TC/unit/utc_ApplicationFW_aul_launch_argv_handler_func.c
new file mode 100644 (file)
index 0000000..905505f
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *  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 <tet_api.h>
+#include <Ecore.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_launch_argv_handler_func_01(void);
+static void utc_ApplicationFW_aul_launch_argv_handler_func_02(void);
+
+enum {
+       NEGATIVE_TC_IDX = 0x01,
+       POSITIVE_TC_IDX = 0x02,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_launch_argv_handler_func_02, NEGATIVE_TC_IDX },
+       { utc_ApplicationFW_aul_launch_argv_handler_func_01, POSITIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+       sleep(3);
+}
+
+/**
+ * @brief Positive test case of aul_launch_argv_handler()
+ */
+static void utc_ApplicationFW_aul_launch_argv_handler_func_01(void)
+{
+       int r = 0;
+
+       ecore_init();
+       aul_launch_init(NULL,NULL);
+       r = aul_launch_argv_handler(0, NULL);
+
+       if (r<0) {
+               tet_infoline("aul_launch_argv_handler() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       ecore_shutdown();
+}
+
+/**
+ * @brief Negative test case of ug_init aul_launch_argv_handler()
+ */
+static void utc_ApplicationFW_aul_launch_argv_handler_func_02(void)
+{
+       int r = 0;
+
+       r = aul_launch_argv_handler(0,NULL);
+
+       if (r>=0) {
+               tet_infoline("aul_launch_argv_handler() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_launch_init_func.c b/TC/unit/utc_ApplicationFW_aul_launch_init_func.c
new file mode 100644 (file)
index 0000000..fed2dfb
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  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 <tet_api.h>
+#include <Ecore.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_launch_init_func_01(void);
+static void utc_ApplicationFW_aul_launch_init_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_launch_init_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_launch_init_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+       sleep(3);
+}
+
+/**
+ * @brief Positive test case of aul_launch_init()
+ */
+static void utc_ApplicationFW_aul_launch_init_func_01(void)
+{
+       int r = 0;
+
+       ecore_init();
+       r = aul_launch_init(NULL,NULL);
+
+       if (r<0) {
+               tet_infoline("aul_launch_init() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       ecore_shutdown();
+}
+
+/**
+ * @brief Negative test case of ug_init aul_launch_init()
+ */
+static void utc_ApplicationFW_aul_launch_init_func_02(void)
+{
+       int r = 0;
+
+       r = aul_launch_init(NULL,NULL);
+
+       if (r>=0) {
+               tet_infoline("aul_launch_init() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_open_app_func.c b/TC/unit/utc_ApplicationFW_aul_open_app_func.c
new file mode 100644 (file)
index 0000000..c9a70ca
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_open_app_func_01(void);
+static void utc_ApplicationFW_aul_open_app_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_open_app_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_open_app_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_open_app()
+ */
+static void utc_ApplicationFW_aul_open_app_func_01(void)
+{
+       int r = 0;
+
+       pid = aul_launch_app(EXIST_PKGNAME,NULL);
+       sleep(1);
+       r = aul_open_app(EXIST_PKGNAME);
+
+       if (r<0) {
+               tet_infoline("aul_open_app() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       aul_terminate_pid(pid);
+       sleep(2);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_open_app()
+ */
+static void utc_ApplicationFW_aul_open_app_func_02(void)
+{
+       int r = 0;
+
+       r = aul_open_app(NO_EXIST_PKGNAME);
+
+       if (r>=0) {
+               tet_infoline("aul_open_app() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_open_content_func.c b/TC/unit/utc_ApplicationFW_aul_open_content_func.c
new file mode 100644 (file)
index 0000000..3053efb
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_open_content_func_01(void);
+static void utc_ApplicationFW_aul_open_content_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_open_content_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_open_content_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_open_content()
+ */
+static void utc_ApplicationFW_aul_open_content_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       r = aul_open_content(CONTENT);
+
+       if (r<0) {
+               tet_infoline("aul_open_content() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       aul_terminate_pid(r);
+       sleep(2);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_open_content()
+ */
+static void utc_ApplicationFW_aul_open_content_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = aul_open_content(NULL);
+
+       if (r>=0) {
+               tet_infoline("aul_open_content() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_open_file_func.c b/TC/unit/utc_ApplicationFW_aul_open_file_func.c
new file mode 100644 (file)
index 0000000..f1a5b98
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_open_file_func_01(void);
+static void utc_ApplicationFW_aul_open_file_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_open_file_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_open_file_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_open_file()
+ */
+static void utc_ApplicationFW_aul_open_file_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       r = aul_open_file(EXIST_FILENAME);
+
+       if (r<0) {
+               tet_infoline("aul_open_file() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       aul_terminate_pid(r);
+       sleep(2);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_open_file()
+ */
+static void utc_ApplicationFW_aul_open_file_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = aul_open_file(NOEXIST_FILENAME);
+
+       if (r>=0) {
+               tet_infoline("aul_open_file() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_open_file_with_mimetype_func.c b/TC/unit/utc_ApplicationFW_aul_open_file_with_mimetype_func.c
new file mode 100644 (file)
index 0000000..77cefc2
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_open_file_with_mimetype_func_01(void);
+static void utc_ApplicationFW_aul_open_file_with_mimetype_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_open_file_with_mimetype_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_open_file_with_mimetype_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_open_file_with_mimetype()
+ */
+static void utc_ApplicationFW_aul_open_file_with_mimetype_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       r = aul_open_file_with_mimetype(EXIST_FILENAME, MIMETYPE);
+
+       if (r<0) {
+               tet_infoline("aul_open_file_with_mimetype() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       aul_terminate_pid(r);
+       sleep(2);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_open_file_with_mimetype()
+ */
+static void utc_ApplicationFW_aul_open_file_with_mimetype_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = aul_open_file_with_mimetype(EXIST_FILENAME, NULL);
+
+       if (r>=0) {
+               tet_infoline("aul_open_file_with_mimetype() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_resume_pid_func.c b/TC/unit/utc_ApplicationFW_aul_resume_pid_func.c
new file mode 100644 (file)
index 0000000..b94dbb8
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_resume_pid_func_01(void);
+static void utc_ApplicationFW_aul_resume_pid_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_resume_pid_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_resume_pid_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_resume_pid()
+ */
+static void utc_ApplicationFW_aul_resume_pid_func_01(void)
+{
+       int r = 0;
+
+       pid = aul_launch_app(EXIST_PKGNAME,NULL);
+       sleep(1);
+       r = aul_resume_pid(pid);
+
+       if (r<0) {
+               tet_infoline("aul_resume_pid() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+       aul_terminate_pid(pid);
+       sleep(2);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_resume_pid()
+ */
+static void utc_ApplicationFW_aul_resume_pid_func_02(void)
+{
+       int r = 0;
+
+       r = aul_resume_pid(-1);
+
+       if (r>=0) {
+               tet_infoline("aul_resume_pid() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_set_defapp_with_mime_func.c b/TC/unit/utc_ApplicationFW_aul_set_defapp_with_mime_func.c
new file mode 100644 (file)
index 0000000..91ae9f6
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_set_defapp_with_mime_func_01(void);
+static void utc_ApplicationFW_aul_set_defapp_with_mime_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_set_defapp_with_mime_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_set_defapp_with_mime_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_set_defapp_with_mime()
+ */
+static void utc_ApplicationFW_aul_set_defapp_with_mime_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       aul_get_defapp_from_mime(MIMETYPE,buf,sizeof(buf));
+       r = aul_set_defapp_with_mime(MIMETYPE,EXIST_PKGNAME);
+
+       if (r<0) {
+               tet_infoline("aul_set_defapp_with_mime() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       aul_set_defapp_with_mime(MIMETYPE,buf);
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of aul_set_defapp_with_mime()
+ */
+static void utc_ApplicationFW_aul_set_defapp_with_mime_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = aul_set_defapp_with_mime(MIMETYPE,NULL);
+
+       if (r>=0) {
+               tet_infoline("aul_set_defapp_with_mime() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_aul_terminate_pid_func.c b/TC/unit/utc_ApplicationFW_aul_terminate_pid_func.c
new file mode 100644 (file)
index 0000000..a996041
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ *  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 <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_aul_terminate_pid_func_01(void);
+static void utc_ApplicationFW_aul_terminate_pid_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_aul_terminate_pid_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_aul_terminate_pid_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of aul_terminate_pid()
+ */
+static void utc_ApplicationFW_aul_terminate_pid_func_01(void)
+{
+       int r = 0;
+
+       pid = aul_launch_app(EXIST_PKGNAME,NULL);
+       sleep(1);
+       r = aul_terminate_pid(pid);
+
+       if (r<0) {
+               tet_infoline("aul_terminate_pid() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init aul_terminate_pid()
+ */
+static void utc_ApplicationFW_aul_terminate_pid_func_02(void)
+{
+       int r = 0;
+
+       r = aul_terminate_pid(-1);
+
+       if (r>=0) {
+               tet_infoline("aul_terminate_pid() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_MODULE_API_func.c.in b/TC/unit/utc_MODULE_API_func.c.in
new file mode 100644 (file)
index 0000000..5edf1b7
--- /dev/null
@@ -0,0 +1,67 @@
+#include <tet_api.h>
+#include "pkgname.h"
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_@MODULE@_@API@_func_01(void);
+static void utc_@MODULE@_@API@_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_@MODULE@_@API@_func_01, POSITIVE_TC_IDX },
+       { utc_@MODULE@_@API@_func_02, NEGATIVE_TC_IDX },
+};
+
+static int pid;
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of @API@()
+ */
+static void utc_@MODULE@_@API@_func_01(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+       
+       r = @API@(...);
+
+       if (r<0) {
+               tet_infoline("@API@() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of ug_init @API@()
+ */
+static void utc_@MODULE@_@API@_func_02(void)
+{
+       int r = 0;
+       char buf[MAX_LOCAL_BUFSZ];
+
+       r = @API@(...);
+
+       if (r>=0) {
+               tet_infoline("@API@() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/aul.pc.in b/aul.pc.in
new file mode 100644 (file)
index 0000000..edb7e62
--- /dev/null
+++ b/aul.pc.in
@@ -0,0 +1,13 @@
+# 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}
diff --git a/data/aul_mime.sh b/data/aul_mime.sh
new file mode 100755 (executable)
index 0000000..80a7153
--- /dev/null
@@ -0,0 +1,28 @@
+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
diff --git a/data/aul_service.sh b/data/aul_service.sh
new file mode 100755 (executable)
index 0000000..bae3153
--- /dev/null
@@ -0,0 +1,28 @@
+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
diff --git a/data/aul_service_test.sh b/data/aul_service_test.sh
new file mode 100755 (executable)
index 0000000..31add47
--- /dev/null
@@ -0,0 +1,15 @@
+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')"
diff --git a/data/create_default_service.sh b/data/create_default_service.sh
new file mode 100755 (executable)
index 0000000..5dbed2a
--- /dev/null
@@ -0,0 +1,96 @@
+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
+
diff --git a/data/mida_db.sql b/data/mida_db.sql
new file mode 100644 (file)
index 0000000..6fdaf1e
--- /dev/null
@@ -0,0 +1,47 @@
+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");
+
diff --git a/data/miregex/callto.uri b/data/miregex/callto.uri
new file mode 100644 (file)
index 0000000..9fe2628
--- /dev/null
@@ -0,0 +1,2 @@
+^( )*callto:(//+)?(\+)?[0-9]+$
+Call Client
diff --git a/data/miregex/contact_shortcut.uri b/data/miregex/contact_shortcut.uri
new file mode 100644 (file)
index 0000000..f81d208
--- /dev/null
@@ -0,0 +1,2 @@
+(^( )*contact_shortcut:)([0-9]+:)([+]|[#]+)?([0-9]+)
+Contact Shortcut Internal
diff --git a/data/miregex/email.uri b/data/miregex/email.uri
new file mode 100644 (file)
index 0000000..bc2ee76
--- /dev/null
@@ -0,0 +1,2 @@
+(^( )*mailto:[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)|(^( )*[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)
+Email Client
diff --git a/data/miregex/file.uri b/data/miregex/file.uri
new file mode 100644 (file)
index 0000000..97dbbc9
--- /dev/null
@@ -0,0 +1,2 @@
+^( )*file:///?[a-zA-Z0-9._-]+
+Browser or FileManager client
diff --git a/data/miregex/http.uri b/data/miregex/http.uri
new file mode 100644 (file)
index 0000000..2697f3c
--- /dev/null
@@ -0,0 +1,2 @@
+(^( )*http(s)?://)|(^( )*www.)
+Browser Client
diff --git a/data/miregex/im.uri b/data/miregex/im.uri
new file mode 100644 (file)
index 0000000..33dcd35
--- /dev/null
@@ -0,0 +1 @@
+^( )*im:[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]*
diff --git a/data/miregex/location.uri b/data/miregex/location.uri
new file mode 100644 (file)
index 0000000..54b0f99
--- /dev/null
@@ -0,0 +1 @@
+^( )*[NSWE]( )*[0-9]+(.[0-9]+)*([ ,;])*[NSWE]( )*[0-9]+(.[0-9]+)*
diff --git a/data/miregex/mmsto.uri b/data/miregex/mmsto.uri
new file mode 100644 (file)
index 0000000..d8a6bed
--- /dev/null
@@ -0,0 +1 @@
+^( )*mmsto:(\+)?[0-9-]+\?cc=(([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)|((\+)?[0-9-]+))?&subject=.+$
diff --git a/data/miregex/phonenum.uri b/data/miregex/phonenum.uri
new file mode 100644 (file)
index 0000000..9fb5643
--- /dev/null
@@ -0,0 +1 @@
+^(\+)?[0-9/.-]*(\\([0-9]+\\))?[0-9/.-]{7,}
diff --git a/data/miregex/sms.uri b/data/miregex/sms.uri
new file mode 100644 (file)
index 0000000..ffadb78
--- /dev/null
@@ -0,0 +1 @@
+^( )*sms:(\+)?[0-9-]+$
diff --git a/data/miregex/tel.uri b/data/miregex/tel.uri
new file mode 100644 (file)
index 0000000..47fe533
--- /dev/null
@@ -0,0 +1 @@
+^( )*tel:(//+)?(\+)?[0-9-]+$
diff --git a/data/service/README b/data/service/README
new file mode 100644 (file)
index 0000000..0be6f7c
--- /dev/null
@@ -0,0 +1 @@
+system service directory
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..8ab59c9
--- /dev/null
@@ -0,0 +1,7 @@
+aul-1 (0.0.154-3) unstable; urgency=low
+
+  * Initial release
+  * Git: pkgs/a/aul-1
+  * Tag: aul-1_0.0.154-3
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 07 Dec 2011 14:05:55 +0900
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..78a8785
--- /dev/null
@@ -0,0 +1,31 @@
+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
+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)
+
diff --git a/debian/dirs b/debian/dirs
new file mode 100644 (file)
index 0000000..ca882bb
--- /dev/null
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin
diff --git a/debian/docs b/debian/docs
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/debian/libaul-1-dev.install.in b/debian/libaul-1-dev.install.in
new file mode 100644 (file)
index 0000000..0f2a4da
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/include/*
+@PREFIX@/lib/pkgconfig/*.pc
diff --git a/debian/libaul-1-executable.install.in b/debian/libaul-1-executable.install.in
new file mode 100644 (file)
index 0000000..4d08215
--- /dev/null
@@ -0,0 +1,5 @@
+@PREFIX@/bin/aul_test
+@PREFIX@/bin/launch_app
+@PREFIX@/bin/launchpad_preloading_preinitializing_daemon
+@PREFIX@/bin/ac_daemon
+/etc/*
diff --git a/debian/libaul-1-executable.postinst b/debian/libaul-1-executable.postinst
new file mode 100644 (file)
index 0000000..9ad55cd
--- /dev/null
@@ -0,0 +1,9 @@
+#!/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
diff --git a/debian/libaul-1.install.in b/debian/libaul-1.install.in
new file mode 100644 (file)
index 0000000..5bf6fbe
--- /dev/null
@@ -0,0 +1,5 @@
+@PREFIX@/lib/libaul.*\r
+@PREFIX@/bin/aul_service.sh\r
+@PREFIX@/bin/aul_service_test.sh\r
+@PREFIX@/bin/aul_mime.sh\r
+/opt/share/*\r
diff --git a/debian/libaul-1.postinst b/debian/libaul-1.postinst
new file mode 100644 (file)
index 0000000..2e32be8
--- /dev/null
@@ -0,0 +1,18 @@
+#!/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
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..225e645
--- /dev/null
@@ -0,0 +1,126 @@
+#!/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
diff --git a/image/high-level.png b/image/high-level.png
new file mode 100644 (file)
index 0000000..d90c0c9
Binary files /dev/null and b/image/high-level.png differ
diff --git a/image/high-level2.png b/image/high-level2.png
new file mode 100644 (file)
index 0000000..957d2a6
Binary files /dev/null and b/image/high-level2.png differ
diff --git a/image/low-level.png b/image/low-level.png
new file mode 100644 (file)
index 0000000..9a6ede3
Binary files /dev/null and b/image/low-level.png differ
diff --git a/image/low-level2.png b/image/low-level2.png
new file mode 100644 (file)
index 0000000..2efb99f
Binary files /dev/null and b/image/low-level2.png differ
diff --git a/include/SLP_AUL_PG.h b/include/SLP_AUL_PG.h
new file mode 100755 (executable)
index 0000000..60fe408
--- /dev/null
@@ -0,0 +1,474 @@
+/*
+ *  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
+@}
+*/
+
+
diff --git a/include/app_signal.h b/include/app_signal.h
new file mode 100755 (executable)
index 0000000..ad8fa49
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ *  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"
+
+#endif
diff --git a/include/app_sock.h b/include/app_sock.h
new file mode 100755 (executable)
index 0000000..c69cd53
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *  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_T_
+#define __APP_PKT_T_
+
+#include <unistd.h>
+#define __USE_GNU
+#include <sys/socket.h>
+#include <linux/un.h>
+
+enum app_cmd {
+       APP_START,
+       APP_RESUME,
+       APP_RESUME_BY_PID,
+       APP_TERM_BY_PID,
+       APP_RESULT,
+       APP_START_RES,
+       APP_CANCEL,
+       APP_KILL_BY_PID
+};
+
+#define AUL_SOCK_PREFIX "/tmp/alaunch"
+#define AUL_SOCK_MAXBUFF 65535
+#define LAUNCHPAD_PID -1
+#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);
+
+#endif
+
diff --git a/include/aul.h b/include/aul.h
new file mode 100755 (executable)
index 0000000..c1b7ecd
--- /dev/null
@@ -0,0 +1,1440 @@
+/*
+ *  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;
+
+/** @} */ 
+
+/**
+ * @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__"
+
+/** 
+ * @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 *pkgname, 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 *pkgname);
+
+/**
+ * @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 or multiple instance, this API launch App. with bundle.
+ *     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 or to 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
+ * @param[in]  kb              bundle to be passed to callee in case of launching app
+ * @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",NULL);
+ * }
+ *
+ * @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 *pkgname, bundle *kb)
+           __attribute__ ((__deprecated__));
+
+/**
+ * @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;         /**< APN (application package name) */
+       char* app_path;         /**< application excutable path */
+} 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 *pkgname);
+
+/**
+ * @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->pkg_name);
+ *     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);
+
+/** @} */
+
+/**
+ * @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(package name) 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 package name 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(package name) 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 package name 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(package name) 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 package name 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);
+
+
+/** @} */
+
+
+
+#ifdef __cplusplus
+       }
+#endif
+
+
+#endif         /* __AUL_H__ */
+
+/* vi: set ts=8 sts=8 sw=8: */
diff --git a/include/aul_api.h b/include/aul_api.h
new file mode 100755 (executable)
index 0000000..7dba195
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ *  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
diff --git a/include/aul_service.h b/include/aul_service.h
new file mode 100755 (executable)
index 0000000..f34e650
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ *  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"
diff --git a/include/launch.h b/include/launch.h
new file mode 100755 (executable)
index 0000000..b52e3ca
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ *  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_
+
+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);
+
+#endif
diff --git a/include/menu_db_util.h b/include/menu_db_util.h
new file mode 100755 (executable)
index 0000000..8b6a814
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ *  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 *app_type;         /* x_slp_packagetype */
+       int width;              /* x_slp_baselayoutwidth */
+       int height;             /* x_slp_baselayoutheight */
+       int vertical;           /* x_slp_ishorizontalscale */
+       int multiple;           /* x_slp_multiple */
+       int task_manage;        /* x_slp_taskmanage */
+       char *pkg_type;
+} app_info_from_db;
+
+static inline char *_get_pkgname(app_info_from_db *menu_info)
+{
+       if (menu_info->pkg_name == NULL)
+               return NULL;
+       return menu_info->pkg_name;
+}
+
+static inline char *_get_app_path(app_info_from_db *menu_info)
+{
+       int i = 0;
+       int path_len = -1;
+
+       if (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)
+{
+       if (menu_info->original_app_path == NULL)
+               return NULL;
+       return menu_info->original_app_path;
+}
+
+static inline char *_get_app_app_type(app_info_from_db *menu_info)
+{
+       return menu_info->app_type;
+}
+
+static inline int _get_app_width(app_info_from_db *menu_info)
+{
+       return menu_info->width;
+}
+
+static inline int _get_app_height(app_info_from_db *menu_info)
+{
+       return menu_info->height;
+}
+
+static inline int _is_app_scalable_with_height(app_info_from_db *menu_info)
+{
+       if (menu_info->vertical)
+               return 0;
+       else
+               return 1;
+}
+
+static inline int _is_app_multi_inst(app_info_from_db *menu_info)
+{
+       if (menu_info->multiple)
+               return 1;
+       else
+               return 0;
+}
+
+static inline int _get_app_task_manage(app_info_from_db *menu_info)
+{
+       return menu_info->task_manage;
+}
+
+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->app_type != NULL)
+                       free(menu_info->app_type);
+               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_package_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_int(handle, AIL_PROP_X_SLP_BASELAYOUTWIDTH_INT, &menu_info->width);
+       
+       ret = ail_appinfo_get_int(handle, AIL_PROP_X_SLP_BASELAYOUTHEIGHT_INT, &menu_info->height);
+       
+       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, &menu_info->vertical);
+       
+       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_MULTIPLE_BOOL, &menu_info->multiple);
+       
+       ret = ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_TASKMANAGE_BOOL, &menu_info->task_manage);
+       
+       ret = ail_appinfo_get_str(handle, AIL_PROP_TYPE_STR, &str);
+       if (str) {
+               menu_info->app_type = strdup(str);
+               str = NULL;
+       }
+
+       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_package_destroy_appinfo(handle);
+       if (ret != AIL_ERROR_OK) {
+               _E("ail_package_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_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
+
+       menu_info->pkg_name = strdup(package);
+       
+       return AIL_CB_RET_CANCEL;       /*return AIL_CB_RET_CONTINUE;*/ 
+}
+
+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;
+       
+}
+
diff --git a/include/mida.h b/include/mida.h
new file mode 100755 (executable)
index 0000000..271f951
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ *  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__ */
+
diff --git a/include/miregex.h b/include/miregex.h
new file mode 100755 (executable)
index 0000000..db8b8db
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ *  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
+
diff --git a/include/perf.h b/include/perf.h
new file mode 100755 (executable)
index 0000000..fb2582f
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ *  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
+
diff --git a/include/pg-doxy/doxygen.conf b/include/pg-doxy/doxygen.conf
new file mode 100755 (executable)
index 0000000..a7cd424
--- /dev/null
@@ -0,0 +1,850 @@
+# 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
diff --git a/include/pg-doxy/pg-doxy.sh b/include/pg-doxy/pg-doxy.sh
new file mode 100755 (executable)
index 0000000..c756291
--- /dev/null
@@ -0,0 +1,39 @@
+#!/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;
+
diff --git a/include/pg-doxy/slp_doxy.css b/include/pg-doxy/slp_doxy.css
new file mode 100644 (file)
index 0000000..12c03ac
--- /dev/null
@@ -0,0 +1,699 @@
+/* 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;
+}
+
diff --git a/include/pg-doxy/tool/bin/doxygen b/include/pg-doxy/tool/bin/doxygen
new file mode 100755 (executable)
index 0000000..3662da8
Binary files /dev/null and b/include/pg-doxy/tool/bin/doxygen differ
diff --git a/include/pg-doxy/tool/bin/doxytag b/include/pg-doxy/tool/bin/doxytag
new file mode 100755 (executable)
index 0000000..adb0c90
Binary files /dev/null and b/include/pg-doxy/tool/bin/doxytag differ
diff --git a/include/pg-doxy/tool/man/man1/doxygen.1 b/include/pg-doxy/tool/man/man1/doxygen.1
new file mode 100644 (file)
index 0000000..a3d8c9a
--- /dev/null
@@ -0,0 +1,46 @@
+.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).
diff --git a/include/pg-doxy/tool/man/man1/doxytag.1 b/include/pg-doxy/tool/man/man1/doxytag.1
new file mode 100644 (file)
index 0000000..f496899
--- /dev/null
@@ -0,0 +1,21 @@
+.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).
diff --git a/include/simple_util.h b/include/simple_util.h
new file mode 100755 (executable)
index 0000000..eed476d
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ *  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 "AULD"
+#else
+#undef LOG_TAG
+#define LOG_TAG "AUL"
+#endif
+
+#define MAX_LOCAL_BUFSZ 128
+#define MAX_PID_STR_BUFSZ 20
+
+#define _E(fmt, arg...) LOGE("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##arg)
+#define _D(fmt, arg...) LOGD("[%s,%d] "fmt, __FUNCTION__, __LINE__, ##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);
+
+#endif
diff --git a/launchpad_run b/launchpad_run
new file mode 100755 (executable)
index 0000000..47c3090
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+mkdir /tmp/alaunch
+chmod 1777 /tmp/alaunch
+/usr/bin/launchpad_preloading_preinitializing_daemon "                                                                                                                                                                                                         " &
+/usr/bin/ac_daemon &
diff --git a/launchpad_src/access_control.h b/launchpad_src/access_control.h
new file mode 100755 (executable)
index 0000000..c9a7496
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  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 <sys/types.h>
+#include <sys/xattr.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <privilege-control.h>
+
+#define INHOUSE_UID     5000
+#define LABEL_LEN              23
+
+static inline void __dac_init()
+{
+}
+
+static inline int __set_dac(const char *pkg_name)
+{
+       return set_privilege(pkg_name);
+}
+
+static inline int __set_smack(char* path)
+{
+/*
+ * This is additional option.
+ * Though such a application fails in this function, that error is ignored.
+ */
+       char label[LABEL_LEN + 1] = {0, };
+       int fd = 0;
+       int result = -1;
+
+       result = getxattr(path, "security.SMACK64EXEC", label, LABEL_LEN);
+       if(result < 0)  // fail to get extended attribute
+               return 0;       // ignore error
+
+       fd = open("/proc/self/attr/current", O_RDWR);
+       if(fd < 0)              // fail to open file
+               return 0;       // ignore error
+
+       result = write(fd, label, strlen(label));
+       if(result < 0) {        // fail to write label
+               close(fd);
+               return 0;       // ignore error
+       }
+
+       close(fd);
+       return 0;
+}
+
+#else
+static inline void __dac_init()
+{
+}
+
+static inline int __set_dac(const char *pkg_name)
+{
+       return 0;
+}
+
+static inline int __set_smack(char* path)
+{
+       return 0;
+}
+#endif
+
+
diff --git a/launchpad_src/config.h b/launchpad_src/config.h
new file mode 100755 (executable)
index 0000000..378f3cf
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ *  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 GL_ACTIVATE*/
+/*#define HEAPDGB_ACTIVATE*/
+/*#define PERF_ACTIVATE*/
+
diff --git a/launchpad_src/gl.h b/launchpad_src/gl.h
new file mode 100755 (executable)
index 0000000..4add496
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  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
+
diff --git a/launchpad_src/heap_dbg.h b/launchpad_src/heap_dbg.h
new file mode 100755 (executable)
index 0000000..7b6c718
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ *  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
diff --git a/launchpad_src/launchpad.c b/launchpad_src/launchpad.c
new file mode 100755 (executable)
index 0000000..ee845b9
--- /dev/null
@@ -0,0 +1,924 @@
+/*
+ *  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 "perf.h"
+#include "sigchild.h"
+
+#include "heap_dbg.h"
+
+#include "util_x.h"
+
+#include "gl.h"
+
+#include <app-checker.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/apps"
+#define PATH_DATA "/data"
+#define SDK_CODE_COVERAGE "CODE_COVERAGE"
+
+static double root_width;
+static double root_height;
+static int scale_factor_init = 0;
+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 void __fill_argv(const char *key, const char *value, void *data);
+_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_ int __add_history(int caller, int callee, const char *pkgname);
+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_ int __app_process_by_pid(int cmd, 
+       const char *pkg_name, struct ucred *cr);
+_static_ int __nofork_processing(int cmd, int pid, bundle * kb);
+_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();
+
+
+
+
+_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_env(app_info_from_db * menu_info, bundle * kb)
+{
+       char buf[MAX_LOCAL_BUFSZ];
+       const char *str;
+       int ret;
+
+       if (scale_factor_init) {
+               if (_is_app_scalable_with_height(menu_info)) {
+                       if (_get_app_height(menu_info) == 0)
+                               snprintf(buf, MAX_LOCAL_BUFSZ, "%lf", 1.0);
+                       else
+                               snprintf(buf, MAX_LOCAL_BUFSZ, "%lf",
+                                        root_height /
+                                        _get_app_height(menu_info));
+               } else {
+                       if (_get_app_width(menu_info) == 0)
+                               snprintf(buf, MAX_LOCAL_BUFSZ, "%lf", 1.0);
+                       else
+                               snprintf(buf, MAX_LOCAL_BUFSZ, "%lf",
+                                        root_width /
+                                        _get_app_width(menu_info));
+               }
+
+               _D("changed scale factor = %s", buf);
+
+               setenv("ELM_SCALE", buf, 1);
+               setenv("SCALE_FACTOR", buf, 1);
+       }
+
+       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);
+
+       str = bundle_get_val(kb, AUL_K_SDK);
+       if(str != NULL) {
+               _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);
+               }
+       }
+
+}
+
+_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();
+
+       /* SET OOM*/
+       __set_oom();
+
+       /* SET SMACK LABEL */
+       __set_smack(app_path);
+
+       /* SET DAC*/
+       if (__set_dac(pkg_name) < 0) {
+               _D("fail to set DAC - 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 int __g_argv_pos = 0;
+static void __fill_argv(const char *key, const char *value, void *data)
+{
+       char **argv;
+       argv = (char **)data;
+
+       argv[__g_argv_pos] = (char *)key;
+       argv[__g_argv_pos + 1] = (char *)value;
+
+       __g_argv_pos += 2;
+}
+
+_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);
+}
+
+_static_ int __add_history(int caller, int callee, const char *pkgname)
+{
+       /* TODO - make real history */
+       _D("***** HISTORY *****\n");
+       _D("%d ==> %d(%s) \n", caller, callee, pkgname);
+       _D("*******************\n");
+
+       return 0;
+}
+
+/*
+ * 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)
+{
+       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);
+       bundle_del(kb, AUL_K_PKG_NAME);
+       if (cmd == APP_START_RES)
+               bundle_add(kb, AUL_K_WAIT_RESULT, "1");
+
+       /* Parse app_path to retrieve default bundle*/
+       if (cmd == APP_START || cmd == APP_START_RES || 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_ 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_ int __nofork_processing(int cmd, int pid, bundle * kb)
+{
+       int ret = -1;
+       switch (cmd) {
+       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);
+               PERF("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);
+               PERF("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);
+}
+
+_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 <= 10);     /* max 50*10ms 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_ 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;
+       const char *app_path;
+       int pid = -1;
+       int clifd = -1;
+       struct ucred cr;
+
+       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");
+
+       if (pkt->cmd == APP_RESULT || pkt->cmd == APP_CANCEL) {
+               pid = __foward_cmd(pkt->cmd, kb, cr.pid);
+               goto end;
+       }
+
+       pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME);
+       _D("pkg name : %s\n", pkg_name);
+
+       if (pkt->cmd == APP_TERM_BY_PID || pkt->cmd == APP_RESUME_BY_PID ||
+           pkt->cmd == APP_KILL_BY_PID) {
+               pid = __app_process_by_pid(pkt->cmd, pkg_name, &cr);
+               goto end;
+       }
+
+       menu_info = _get_app_info_from_db_by_pkgname(pkg_name);
+       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");
+
+       if (_is_app_multi_inst(menu_info) == 0)
+               pid = __proc_iter_cmdline(NULL, (void *)app_path);
+
+       PERF("find pid by searching proc file system done");
+
+       if (pid > 0) {
+               int ret;
+
+               if (cr.pid == pid) {
+                       _D("caller process & callee process is same.[%s:%d]",
+                          pkg_name, pid);
+                       pid = -ELOCALLAUNCH_ID;
+               } else if ((ret = __nofork_processing(pkt->cmd, pid, kb)) < 0)
+                       pid = ret;
+       } else {
+               pid = fork();
+               if (pid == 0) {
+                       PERF("fork done");
+                       _E("lock up test log(no error) : fork done");
+
+                       close(clifd);
+                       close(main_fd);
+                       ail_db_close();
+                       __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);
+       }
+
+ end:
+       if (pid > 0)
+               __add_history(cr.pid, pid, pkg_name);
+
+       __send_result_to_caller(clifd, pid);
+
+       if (pid > 0) {
+               int ret;
+               ret = ac_check_launch_privilege(pkg_name, menu_info->pkg_type, pid);
+               _D("ac_check_launch_privilege : %d", ret);
+       }
+
+       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();
+
+       /* dac init*/
+       __dac_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);
+
+       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;
+       }
+
+       x_util_init();
+
+       /* get root window size   */
+       x_util_get_default_size(&root_width, &root_height);
+       scale_factor_init = 1;
+
+       preinit_init();
+       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);
+                       }
+               }
+       }
+}
+
diff --git a/launchpad_src/sigchild.h b/launchpad_src/sigchild.h
new file mode 100755 (executable)
index 0000000..de7a059
--- /dev/null
@@ -0,0 +1,201 @@
+/*
+ *  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;
+
+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 void *__sigchild_thread(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:
+       pthread_exit(0);
+       return 0;
+}
+
+static void __launchpad_sig_child(int signo, siginfo_t *info, void *data)
+{
+       int status;
+       pid_t child_pid;
+       pthread_t thid;
+       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);
+               if (pthread_create(&thid, NULL,
+                                  __sigchild_thread, (void *)child_pid) != 0) {
+                       printf("Failed to create thread\n");
+                       return;
+               }
+               pthread_detach(thid);
+       }
+
+       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_fini(void)
+{
+#ifndef PRELOAD_ACTIVATE
+       int i;
+       for (i = 0; i < _NSIG; i++)
+               signal(i, SIG_DFL);
+#endif
+       return 0;
+}
+
diff --git a/launchpad_src/util_x.c b/launchpad_src/util_x.c
new file mode 100755 (executable)
index 0000000..4e7ecd8
--- /dev/null
@@ -0,0 +1,203 @@
+/*
+ *  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;
+}
+
diff --git a/launchpad_src/util_x.h b/launchpad_src/util_x.h
new file mode 100755 (executable)
index 0000000..650bad5
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ *  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
+
diff --git a/legacy/preload.h b/legacy/preload.h
new file mode 100755 (executable)
index 0000000..e964917
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ *  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 RW_DATA_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(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
+
diff --git a/legacy/preload_list.txt b/legacy/preload_list.txt
new file mode 100644 (file)
index 0000000..8b06c09
--- /dev/null
@@ -0,0 +1,3 @@
+/usr/lib/libappcore-efl.so
+/usr/lib/libappcore-common.so
+/usr/lib/ecore/immodules/libisf-imf-module.so
diff --git a/packaging/aul.spec b/packaging/aul.spec
new file mode 100644 (file)
index 0000000..28c69d0
--- /dev/null
@@ -0,0 +1,83 @@
+Name:       aul
+Summary:    App utility library
+Version:    0.0.134
+Release:    1
+Group:      System/Libraries
+License:    LGPLv2
+Source0:    %{name}-%{version}.tar.bz2
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+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)
+
+
+%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
+chmod +x %{buildroot}/usr/bin/aul_service.sh
+chmod +x %{buildroot}/usr/bin/aul_service_test.sh
+
+
+%post
+/sbin/ldconfig
+
+mkdir -p /etc/rc.d/rc3.d
+mkdir -p /etc/rc.d/rc4.d
+ln -sf /etc/init.d/launchpad_run /etc/rc.d/rc3.d/S35launchpad_run
+ln -sf /etc/init.d/launchpad_run /etc/rc.d/rc4.d/S80launchpad_run
+
+
+%postun -p /sbin/ldconfig
+
+%files
+/usr/lib/*.so.*
+/etc/init.d/launchpad_run
+/usr/bin/aul_service.sh
+/usr/bin/aul_service_test.sh
+/opt/share/mida_db.sql
+/usr/bin/aul_mime.sh
+/usr/bin/aul_test
+/usr/bin/launch_app
+/opt/share/miregex/*
+/opt/share/service/*
+/opt/share/preload_list.txt
+/usr/bin/launchpad_preloading_preinitializing_daemon
+
+%files devel
+/usr/include/aul/*.h
+/usr/lib/*.so
+/usr/lib/pkgconfig/*.pc
+
+
diff --git a/src/app_signal.c b/src/app_signal.c
new file mode 100755 (executable)
index 0000000..bda7d09
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ *  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"
+
+static int (*_app_dead_handler) (int pid, void *data);
+static void *_app_dead_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 dead_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,
+                    &dead_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(dead_pid, _app_dead_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);
+
+       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 -1;
+               }
+       } else {
+               if (__app_dbus_signal_handler_fini() < 0) {
+                       _E("error app signal fini");
+                       return -1;
+               }
+       }
+       _app_dead_handler = func;
+       _app_dead_data = data;
+
+       return 0;
+}
+
diff --git a/src/app_sock.c b/src/app_sock.c
new file mode 100755 (executable)
index 0000000..b469c46
--- /dev/null
@@ -0,0 +1,353 @@
+/*
+ *  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/xattr.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 = { 1, 200 * 1000 };  /*  1.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);
+       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;
+               }
+       }
+
+       bzero(&saddr, 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((fsetxattr(fd, "security.SMACK64IPOUT", "@", 2, 0)) < 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");
+                               return -1;
+                       }
+               }
+               if((fsetxattr(fd, "security.SMACK64IPIN", "*", 2, 0)) < 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");
+                               return -1;
+                       }
+               }
+       }
+
+       if (bind(fd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0) {
+               _E("bind error");
+               return -1;
+       }
+
+       if (chmod(saddr.sun_path, (S_IRWXU | S_IRWXG | S_IRWXO)) < 0) {
+               /* Flawfinder: ignore*/
+               _E("failed to change the socket permission");
+               return -1;
+       }
+
+       __set_sock_option(fd, 0);
+
+       if (listen(fd, 10) == -1) {
+               _E("listen error");
+               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:
+       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", len, datalen + 8);
+               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;
+               }
+       } else
+               _D("recv result  = %d (%d)", res, len);
+       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;
+}
+
diff --git a/src/launch.c b/src/launch.c
new file mode 100755 (executable)
index 0000000..a0931af
--- /dev/null
@@ -0,0 +1,428 @@
+/*
+ *  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"
+
+static int aul_initialized = 0;
+
+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);
+
+
+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
+ */
+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;
+}
+
+/**
+ * @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;
+
+       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(LAUNCHPAD_PID, cmd, kb);
+
+       if (ret == AUL_R_LOCAL) {
+               _E("app_request_to_launchpad : Same Process Send Local");
+               bundle *b;
+
+               b = bundle_dup(kb);
+               ret = __app_launch_local(b);
+       }
+
+       /* 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_RESUME:        /* run in callee */
+       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;
+
+       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()
+{
+       int fd;
+
+       if (aul_initialized) {
+               _E("aul already initialized");
+               return AUL_R_ECANCELED;
+       }
+
+       fd = __create_server_sock(getpid());
+       if (fd < 0) {
+               _E("aul_init create sock failed");
+               return AUL_R_ECOMM;
+       }
+       aul_initialized = 1;
+
+       return fd;
+}
+
+SLPAPI int aul_launch_app(const char *pkgname, bundle *kb)
+{
+       int ret;
+
+       if (pkgname == NULL)
+               return AUL_R_EINVAL;
+
+       ret = app_request_to_launchpad(APP_START, pkgname, kb);
+       return ret;
+}
+
+SLPAPI int aul_open_app(const char *pkgname)
+{
+       int ret;
+
+       if (pkgname == NULL)
+               return AUL_R_EINVAL;
+
+       ret = app_request_to_launchpad(APP_RESUME, pkgname, NULL);
+       return ret;
+}
+
+SLPAPI int aul_resume_app(const char *pkgname, bundle *kb)
+{
+       int ret;
+
+       if (pkgname == NULL)
+               return AUL_R_EINVAL;
+
+       ret = app_request_to_launchpad(APP_RESUME, pkgname, kb);
+       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: */
+
diff --git a/src/launch_glib.c b/src/launch_glib.c
new file mode 100755 (executable)
index 0000000..19b82ad
--- /dev/null
@@ -0,0 +1,156 @@
+/*
+ *  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 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 __aul_glib_handler(gpointer data);
+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;
+}
+
+static GSourceFuncs funcs = {
+       .prepare = __aul_glib_prepare,
+       .check = __aul_glib_check,
+       .dispatch = __aul_glib_dispatch,
+       .finalize = NULL
+};
+
+static 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;
+       GSource *src;
+       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_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_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;
+}
+
diff --git a/src/launch_with_result.c b/src/launch_with_result.c
new file mode 100755 (executable)
index 0000000..ab331e3
--- /dev/null
@@ -0,0 +1,396 @@
+/*
+ *  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"
+
+/*#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 = 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 = 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(LAUNCHPAD_PID, (is_cancel==1)? APP_CANCEL : APP_RESULT, kb);
+       
+       if(latest_caller_pid == pid)
+               latest_caller_pid = -1;
+
+       return ret;
+}
+
diff --git a/src/mida.c b/src/mida.c
new file mode 100755 (executable)
index 0000000..be597a1
--- /dev/null
@@ -0,0 +1,516 @@
+/*
+ *  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;
+}
+
diff --git a/src/mime.c b/src/mime.c
new file mode 100755 (executable)
index 0000000..7f1a684
--- /dev/null
@@ -0,0 +1,423 @@
+/*
+ *  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_package_get_appinfo(defapp, &handle);
+
+               if (ail_ret == AIL_ERROR_OK) {
+                       ail_package_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_package_destroy_appinfo(handle);
+                       goto retry;
+               } else {
+                       _E("ail_package_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);
+}
+
diff --git a/src/miregex.c b/src/miregex.c
new file mode 100755 (executable)
index 0000000..ead5308
--- /dev/null
@@ -0,0 +1,243 @@
+/*
+ *  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 RW_DATA_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;
+}
+
diff --git a/src/pkginfo.c b/src/pkginfo.c
new file mode 100755 (executable)
index 0000000..d9b828a
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ *  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"
+
+typedef struct _internal_param_t {
+       aul_app_info_iter_fn enum_fn;
+       void *user_param;
+} internal_param_t;
+
+static int __get_pkginfo(const char *dname, const char *cmdline, void *priv);
+static int __get_pkgname_bypid(int pid, char *pkgname, int len);
+
+
+SLPAPI int aul_app_is_running(const char *pkgname)
+{
+       char *apppath = NULL;
+       ail_appinfo_h handle;
+       ail_error_e ail_ret;
+
+       int ret = 0;
+       int i = 0;
+
+       if (pkgname == NULL)
+               return 0;
+
+       ail_ret = ail_package_get_appinfo(pkgname, &handle);
+       if (ail_ret != AIL_ERROR_OK) {
+               _E("ail_package_get_appinfo with %s failed", pkgname);
+               return ret;
+       }
+
+       ail_ret = ail_appinfo_get_str(handle, AIL_PROP_EXEC_STR, &apppath);
+       if (ail_ret != AIL_ERROR_OK) {
+               _E("ail_appinfo_get_str failed");
+               goto out;
+       }
+       
+       if (apppath == NULL)
+               goto out;
+
+       /*truncate apppath if it includes default bundles */
+       while (apppath[i] != 0) {
+               if (apppath[i] == ' ' || apppath[i] == '\t') {
+                       apppath[i]='\0';
+                       break;
+               }
+               i++;
+       }
+       
+       if (__proc_iter_cmdline(NULL, apppath) > 0)
+               ret = 1;
+       else
+               ret = 0;
+
+ out:
+       if (ail_package_destroy_appinfo(handle) != AIL_ERROR_OK)
+               _E("ail_destroy_rs failed");
+       return ret;
+}
+
+static int __get_pkginfo(const char *dname, const char *cmdline, void *priv)
+{
+       internal_param_t *p;
+       app_info_from_db *menu_info;
+       aul_app_info info;
+
+       p = (internal_param_t *) priv;
+       if ((menu_info = _get_app_info_from_db_by_apppath(cmdline)) == NULL)
+               goto out;
+       else {
+               info.pid = atoi(dname);
+               info.pkg_name = _get_pkgname(menu_info);
+               info.app_path = _get_app_path(menu_info);
+               _D("get pkginfo - %d %s", info.pid, info.app_path);
+               p->enum_fn(&info, p->user_param);
+       }
+
+ out:
+       if (menu_info != NULL)
+               _free_app_info_from_db(menu_info);
+       return 0;
+}
+
+SLPAPI int aul_app_get_running_app_info(aul_app_info_iter_fn enum_fn,
+                                       void *user_param)
+{
+       internal_param_t param;
+
+       if (enum_fn == NULL)
+               return AUL_R_EINVAL;
+
+       param.enum_fn = enum_fn;
+       param.user_param = user_param;
+
+       __proc_iter_cmdline(__get_pkginfo, &param);
+
+       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)
+{
+       int pgid;
+
+       if (pkgname == NULL)
+               return AUL_R_EINVAL;
+
+       if (__get_pkgname_bypid(pid, pkgname, len) == 0) {
+               _D("Pkg name for %d is %s", pid, pkgname);
+               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, pkgname, len) == 0)
+               return AUL_R_OK;
+
+       return AUL_R_ERROR;
+}
+
diff --git a/src/service.c b/src/service.c
new file mode 100755 (executable)
index 0000000..ebf28a0
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ *  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"
+
+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_package_get_appinfo(defapp, &handle);
+
+               if (ail_ret == AIL_ERROR_OK) {
+                       ail_package_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_package_destroy_appinfo(handle);
+                       goto retry;
+               } else {
+                       _E("ail_package_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);
+}
+
diff --git a/src/simple_util.c b/src/simple_util.c
new file mode 100755 (executable)
index 0000000..d5bbeda
--- /dev/null
@@ -0,0 +1,210 @@
+/*
+ *  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;
+}
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..fe249f4
--- /dev/null
@@ -0,0 +1,54 @@
+# 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} )
+
+add_executable(ac_daemon
+                ac_daemon.c)
+target_link_libraries(ac_daemon app-checker-server glib-2.0 ${pkgs_LDFLAGS})
+INSTALL(TARGETS ac_daemon DESTINATION bin)
+
+
+
+### 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 ""
+#      )
diff --git a/test/ac_daemon.c b/test/ac_daemon.c
new file mode 100755 (executable)
index 0000000..13f8fd3
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of 
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+this software is owned by Samsung and you 
+shall not disclose such Confidential Information and shall 
+use it only in accordance with the terms of the license agreement 
+you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no 
+representations or warranties about the suitability 
+of the software, either express or implied, including but not 
+limited to the implied warranties of merchantability, fitness for 
+a particular purpose, or non-infringement. 
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or 
+related to this software.
+*/
+
+#include <stdio.h>
+#include <glib.h>
+
+#include <app-checker-server.h>
+
+int main()
+{
+       
+       GMainLoop *mainloop;
+       int ret;
+
+       mainloop = g_main_loop_new(NULL, FALSE);
+
+       ret = ac_server_initailize();
+
+       g_main_loop_run(mainloop);
+
+       return 0;
+}
diff --git a/test/app_test.c b/test/app_test.c
new file mode 100755 (executable)
index 0000000..bd004bc
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of 
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+this software is owned by Samsung and you 
+shall not disclose such Confidential Information and shall 
+use it only in accordance with the terms of the license agreement 
+you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no 
+representations or warranties about the suitability 
+of the software, either express or implied, including but not 
+limited to the implied warranties of merchantability, fitness for 
+a particular purpose, or non-infringement. 
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or 
+related to this software.
+*/
+
+#include <poll.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "aul.h"
+
+/* ecore-glib integration */
+
+#include <Ecore.h>
+
+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;
+}
+
+__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);
+
+       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: */
diff --git a/test/aul_dbus.c b/test/aul_dbus.c
new file mode 100755 (executable)
index 0000000..a6000a5
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of 
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+this software is owned by Samsung and you 
+shall not disclose such Confidential Information and shall 
+use it only in accordance with the terms of the license agreement 
+you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no 
+representations or warranties about the suitability 
+of the software, either express or implied, including but not 
+limited to the implied warranties of merchantability, fitness for 
+a particular purpose, or non-infringement. 
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or 
+related to this software.
+*/
+
+#include <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;
+
+       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);
+
+       dbus_connection_send_with_reply(bus, message, &pc, INT_MAX);
+       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;
+}
+
diff --git a/test/aul_dbus.h b/test/aul_dbus.h
new file mode 100755 (executable)
index 0000000..730cbf7
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of 
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+this software is owned by Samsung and you 
+shall not disclose such Confidential Information and shall 
+use it only in accordance with the terms of the license agreement 
+you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no 
+representations or warranties about the suitability 
+of the software, either express or implied, including but not 
+limited to the implied warranties of merchantability, fitness for 
+a particular purpose, or non-infringement. 
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or 
+related to this software.
+*/
+
+#include <stdio.h>
+#include <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"
diff --git a/test/aul_test.c b/test/aul_test.c
new file mode 100755 (executable)
index 0000000..02bd6df
--- /dev/null
@@ -0,0 +1,673 @@
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of 
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+this software is owned by Samsung and you 
+shall not disclose such Confidential Information and shall 
+use it only in accordance with the terms of the license agreement 
+you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no 
+representations or warranties about the suitability 
+of the software, either express or implied, including but not 
+limited to the implied warranties of merchantability, fitness for 
+a particular purpose, or non-infringement. 
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or 
+related to this software.
+*/
+
+#include <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 resume_test()
+{
+       static int num = 0;
+
+       printf("[aul_open_app %d test] %s \n", num++, gargv[2]);
+       return aul_open_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->pkg_name);
+       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_pkgname_bypid %d test] \n", num++);
+       pid = atoi(gargv[2]);
+
+       if (aul_app_get_pkgname_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 w: %d\n", info->width);
+       printf("\t h: %d\n", info->height);
+       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 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",resume_test,"aul_open_app test",
+               "[usage] open <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_test <pkgname>"},
+       {"getallpkg", get_allpkg_test, "aul_app_get_running_app_info test",
+               "[usage] getallpkg all"},
+       {"getpkgpid", get_pkgpid_test, "aul_app_get_pkgname_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>"},
+/*
+       {"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: */
+
diff --git a/test/dbusapp_test.c b/test/dbusapp_test.c
new file mode 100755 (executable)
index 0000000..c5d7b7a
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of 
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+this software is owned by Samsung and you 
+shall not disclose such Confidential Information and shall 
+use it only in accordance with the terms of the license agreement 
+you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no 
+representations or warranties about the suitability 
+of the software, either express or implied, including but not 
+limited to the implied warranties of merchantability, fitness for 
+a particular purpose, or non-infringement. 
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or 
+related to this software.
+*/
+
+#include <stdio.h>
+#include <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;
+}
+
diff --git a/test/launch_app.c b/test/launch_app.c
new file mode 100755 (executable)
index 0000000..a8acf06
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
+PROPRIETARY/CONFIDENTIAL
+This software is the confidential and proprietary information of 
+SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that 
+this software is owned by Samsung and you 
+shall not disclose such Confidential Information and shall 
+use it only in accordance with the terms of the license agreement 
+you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no 
+representations or warranties about the suitability 
+of the software, either express or implied, including but not 
+limited to the implied warranties of merchantability, fitness for 
+a particular purpose, or non-infringement. 
+SAMSUNG shall not be liable for any damages suffered by licensee arising out of or 
+related to this software.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <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;
+
+       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()
+{
+       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)
+{
+
+       /* Checking the User ID*/
+       if (getuid() != ROOT_UID) {
+               fprintf(stderr, "permission error\n");
+               exit(EXIT_FAILURE);
+       }
+
+       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;
+}
+
diff --git a/test/org.tizen.camera.service b/test/org.tizen.camera.service
new file mode 100644 (file)
index 0000000..4fe4392
--- /dev/null
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.tizen.camera
+Exec=/usr/bin/aul_test dbuslaunch deb.org.tizen.camera