Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:46:31 +0000 (01:46 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:46:31 +0000 (01:46 +0900)
26 files changed:
AUTHORS [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0755]
LICENSE [new file with mode: 0644]
app-svc.manifest [new file with mode: 0644]
appsvc.pc.in [new file with mode: 0755]
data/appsvc_db.sql [new file with mode: 0755]
debian/appsvc-tool.install.in [new file with mode: 0755]
debian/changelog [new file with mode: 0755]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0755]
debian/dirs [new file with mode: 0644]
debian/docs [new file with mode: 0644]
debian/libappsvc-0.install.in [new file with mode: 0755]
debian/libappsvc-0.postinst [new file with mode: 0755]
debian/libappsvc-dev.install.in [new file with mode: 0755]
debian/rules [new file with mode: 0755]
include/appsvc.h [new file with mode: 0755]
include/appsvc_db.h [new file with mode: 0755]
include/internal.h [new file with mode: 0755]
include/priv_key.h [new file with mode: 0755]
packaging/app-svc.spec [new file with mode: 0644]
src/appsvc.c [new file with mode: 0755]
src/appsvc_db.c [new file with mode: 0755]
test/CMakeLists.txt [new file with mode: 0755]
test/a.out [new file with mode: 0755]
test/appsvc_test.c [new file with mode: 0755]

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..ebd300c
--- /dev/null
@@ -0,0 +1,92 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+PROJECT(appsvc 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/appsvc")
+
+# 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 aul)
+pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 ail xdgmime aul glib-2.0 ecore-x ecore libsoup-2.4 iniparser pkgmgr-info)
+
+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(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
+add_library(appsvc SHARED
+               src/appsvc.c
+               src/appsvc_db.c
+               )
+target_link_libraries(appsvc ${libpkgs_LDFLAGS})
+SET_TARGET_PROPERTIES(appsvc PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(appsvc PROPERTIES VERSION ${VERSION})
+
+# pkgconfig file
+CONFIGURE_FILE(appsvc.pc.in appsvc.pc @ONLY)
+
+
+### Install ###
+INSTALL(TARGETS appsvc DESTINATION lib COMPONENT RuntimeLibraries)
+INSTALL(TARGETS ${AVATAR_NAME} DESTINATION bin)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/appsvc.h DESTINATION include/appsvc)
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/appsvc.pc DESTINATION lib/pkgconfig)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/data/appsvc_db.sql 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/app-svc.manifest b/app-svc.manifest
new file mode 100644 (file)
index 0000000..e8f9198
--- /dev/null
@@ -0,0 +1,15 @@
+<manifest>
+       <define>
+               <domain name="app-svc"/>
+               <provide>
+                       <label name="app-svc::db"/>
+               </provide>
+       </define>
+       <request>
+               <domain name="app-svc"/>
+       </request>
+       <assign>
+               <filesystem path="/usr/lib/libappsvc.so.0" label="_"/>
+               <filesystem path="/usr/lib/libappsvc.so.0.1.0" label="_"/>
+       </assign>
+</manifest>
diff --git a/appsvc.pc.in b/appsvc.pc.in
new file mode 100755 (executable)
index 0000000..4037bbb
--- /dev/null
@@ -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 aul
+Libs: -L${libdir} -lappsvc
+Cflags: -I${includedir}
diff --git a/data/appsvc_db.sql b/data/appsvc_db.sql
new file mode 100755 (executable)
index 0000000..290feee
--- /dev/null
@@ -0,0 +1,11 @@
+PRAGMA journal_mode = PERSIST;
+
+CREATE TABLE IF NOT EXISTS appsvc (
+        operation TEXT,
+        mime_type TEXT DEFAULT 'NULL',
+        uri TEXT DEFAULT 'NULL',
+        pkg_name TEXT,
+        PRIMARY KEY (operation,mime_type,uri)
+);
+
+
diff --git a/debian/appsvc-tool.install.in b/debian/appsvc-tool.install.in
new file mode 100755 (executable)
index 0000000..6ee69bd
--- /dev/null
@@ -0,0 +1 @@
+@PREFIX@/bin/appsvc_test
diff --git a/debian/changelog b/debian/changelog
new file mode 100755 (executable)
index 0000000..41f3fc5
--- /dev/null
@@ -0,0 +1,230 @@
+app-svc (0.1.25) unstable; urgency=low
+
+  * changed to use the application ID
+  * Git: slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.25
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 05 Jun 2012 20:46:18 +0900
+
+app-svc (0.1.24) unstable; urgency=low
+
+  * added new API for transient window
+  * Git: slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.24
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 04 Jun 2012 20:00:10 +0900
+
+app-svc (0.1.23) unstable; urgency=low
+
+  * Added error handle for uri
+  * Git: slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.23
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 18 May 2012 11:15:05 +0900
+
+app-svc (0.1.22) unstable; urgency=low
+
+  * Updated uri resolution
+  * Git: slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.22
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 03 Apr 2012 17:59:06 +0900
+
+app-svc (0.1.21) unstable; urgency=low
+
+  * Fixed compile warnings
+  * Git: slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.21
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 20 Mar 2012 14:11:59 +0900
+
+app-svc (0.1.20) unstable; urgency=low
+
+  * Changed operation and extra data format
+  * Git: slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.20
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 15 Mar 2012 17:18:15 +0900
+
+app-svc (0.1.19) unstable; urgency=low
+
+  * Added TC
+  * Git: slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.19
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 19 Dec 2011 14:30:00 +0900
+
+app-svc (0.1.18) unstable; urgency=low
+
+  * Fix appsvc_set_defapp bug
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.18
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 14 Dec 2011 14:53:09 +0900
+
+app-svc (0.1.17) unstable; urgency=low
+
+  * Changed boilerplate
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.17
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 05 Dec 2011 16:45:29 +0900
+
+app-svc (0.1.16) unstable; urgency=low
+
+  * Fix appsvc_test bug
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.16
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 14 Nov 2011 19:52:07 +0900
+
+app-svc (0.1.15) unstable; urgency=low
+
+  * Changed Boilerplate as per the guideline
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.15 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 07 Nov 2011 17:36:50 +0900
+
+app-svc (0.1.14) unstable; urgency=low
+
+  * Fix prevent defects
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.14 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 25 Oct 2011 20:39:26 +0900
+
+app-svc (0.1.13) unstable; urgency=low
+
+  * modify protype of appsvc_set_defapp
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.13 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Sat, 15 Oct 2011 19:42:04 +0900
+
+app-svc (0.1.12) unstable; urgency=low
+
+  * Support array
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.12
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 06 Oct 2011 22:01:02 +0900
+
+app-svc (0.1.11) unstable; urgency=low
+
+  * About explicit svc
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.11 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Wed, 21 Sep 2011 21:08:11 +0900
+
+app-svc (0.1.10) unstable; urgency=low
+
+  * Fix bug
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.10 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Sat, 17 Sep 2011 18:39:01 +0900
+
+app-svc (0.1.9) unstable; urgency=low
+
+  * changelog
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.9 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 05 Sep 2011 21:00:46 +0900
+
+app-svc (0.1.8) unstable; urgency=low
+
+  * Fix prevent defects
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.8 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Mon, 05 Sep 2011 13:46:19 +0900
+
+app-svc (0.1.7) unstable; urgency=low
+
+  * Fix bug
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.7 
+
+ -- Jaeho81.lee <jaeho81.lee@samsung.com>  Wed, 31 Aug 2011 16:32:47 +0900
+
+app-svc (0.1.6) unstable; urgency=low
+
+  * Add appsvc_is_defapp API
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.6 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 25 Aug 2011 20:55:10 +0900
+
+app-svc (0.1.5) unstable; urgency=low
+
+  * Add appsvc_unset_defapp API
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.5 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 25 Aug 2011 09:57:36 +0900
+
+app-svc (0.1.4) unstable; urgency=low
+
+  * Fix prevnet defects
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.4 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Sat, 20 Aug 2011 18:07:30 +0900
+
+app-svc (0.1.3) unstable; urgency=low
+
+  * Fix bug
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.3 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Fri, 19 Aug 2011 16:09:27 +0900
+
+app-svc (0.1.2) unstable; urgency=low
+
+  * Modify comments for build warning
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.2 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Sat, 13 Aug 2011 18:23:56 +0900
+
+app-svc (0.1.1) unstable; urgency=low
+
+  * Fix bug
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.1 
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Thu, 11 Aug 2011 13:18:30 +0900
+
+app-svc (0.1.0-2) unstable; urgency=low
+
+  * Apply appsvc code
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.0-2 
+
+ -- Sewook Park <sewook7.park@samsung.com>  Wed, 10 Aug 2011 21:36:09 +0900
+
+app-svc (0.1.0-1) unstable; urgency=low
+
+  * Apply appsvc code
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.0-1
+
+ -- Sewook Park <sewook7.park@samsung.com>  Wed, 10 Aug 2011 20:54:10 +0900
+
+app-svc (0.1.0) unstable; urgency=low
+
+  * Apply appsvc code
+  * Git: 165.213.180.234:slp/pkgs/a/app-svc
+  * Tag: app-svc_0.1.0
+
+ -- Sewook ParK <sewook7.park@samsung.com>  Wed, 10 Aug 2011 18:48:45 +0900
+
+app-svc (0.0.1) unstable; urgency=low
+
+  * initial update
+
+ -- Jaeho Lee <jaeho81.lee@samsung.com>  Tue, 19 Jul 2011 10:23:24 +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 100755 (executable)
index 0000000..b009b84
--- /dev/null
@@ -0,0 +1,31 @@
+Source: app-svc
+Section: devel
+Priority: extra
+Maintainer: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@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, libaul-1-dev, libecore-dev, libsoup2.4-dev
+Standards-Version: 0.1.0 
+
+Package: libappsvc-dev
+Section: libs
+Architecture: any
+Depends: libappsvc-0 (= ${Source-Version}), libaul-1, libdbus-glib-1-dev, libsqlite3-dev, libbundle-dev, libail-0-dev, dlog-dev, libxdgmime-dev, sqlite3, libaul-1-dev
+Description: libappsvc dev package
+
+Package: libappsvc-0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, sqlite3
+Description: libappsvc-0 package
+
+Package: libappsvc-dbg
+Section: debug
+Architecture: any
+Depends: libappsvc-0 (= ${Source-Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: libappsvc dbg package 
+
+Package: appsvc-tool
+Section: libs
+Architecture: any
+Depends: libappsvc-0 (= ${Source-Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: libappsvc-0 executable package (appsvc_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/libappsvc-0.install.in b/debian/libappsvc-0.install.in
new file mode 100755 (executable)
index 0000000..83f97d6
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/lib/libappsvc.*\r
+/opt/share/*\r
diff --git a/debian/libappsvc-0.postinst b/debian/libappsvc-0.postinst
new file mode 100755 (executable)
index 0000000..31e162c
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+mkdir -p /opt/dbspace
+sqlite3 /opt/dbspace/.appsvc.db < /opt/share/appsvc_db.sql
+rm -rf /opt/share/appsvc_db.sql
+
+if [ "${USER}" = "root" ]
+then
+       chown root:root /usr/lib/libappsvc.so.0.1.0
+       chown root:5000 /opt/dbspace/.appsvc.db
+       chown root:5000 /opt/dbspace/.appsvc.db-journal
+fi
+
+chmod 644 /usr/lib/libappsvc.so.0.1.0
+chmod 664 /opt/dbspace/.appsvc.db
+chmod 664 /opt/dbspace/.appsvc.db-journal
+
+#chmod 1777 /opt/share/miregex # Set directory to be writable for other accounts
diff --git a/debian/libappsvc-dev.install.in b/debian/libappsvc-dev.install.in
new file mode 100755 (executable)
index 0000000..0f2a4da
--- /dev/null
@@ -0,0 +1,2 @@
+@PREFIX@/include/*
+@PREFIX@/lib/pkgconfig/*.pc
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..ac9fca7
--- /dev/null
@@ -0,0 +1,114 @@
+#!/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
+
+CFLAGS += -fvisibility=hidden -fpic
+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
+
+
+       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
+
+
+# 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=libappsvc-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/include/appsvc.h b/include/appsvc.h
new file mode 100755 (executable)
index 0000000..4a98f39
--- /dev/null
@@ -0,0 +1,948 @@
+/*
+ *  app-svc
+ *
+ * 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_SVC_H__
+#define __APP_SVC_H__
+
+/**
+ * @file    appsvc.h
+ * @version 1.1
+ * @brief   This file contains APIs of the appsvc library
+ */
+
+/**
+ * @addtogroup APPLICATION_FRAMEWORK
+ * @{
+ *
+ * @defgroup appsvc Application Service
+ * @version  1.1
+ * @brief    Application Service library
+ *
+ */
+
+/**
+ * @addtogroup appsvc
+ * @{
+ */
+
+
+#include <bundle.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_DEFAULT               "http://tizen.org/appcontrol/operation/default"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_EDIT                  "http://tizen.org/appcontrol/operation/edit"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_VIEW                  "http://tizen.org/appcontrol/operation/view"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_PICK                  "http://tizen.org/appcontrol/operation/pick"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_CREATE_CONTENT                "http://tizen.org/appcontrol/operation/create_content"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_CALL                  "http://tizen.org/appcontrol/operation/call"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_SEND                  "http://tizen.org/appcontrol/operation/send"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_SEND_TEXT             "http://tizen.org/appcontrol/operation/send_text"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_DIAL                  "http://tizen.org/appcontrol/operation/dial"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_SEARCH                        "http://tizen.org/appcontrol/operation/search"
+/** APP_SVC OPERATION TYPE*/
+#define APPSVC_OPERATION_DOWNLOAD              "http://tizen.org/appcontrol/operation/download"
+
+
+/** APP_SVC DATA SUBJECT*/
+#define APPSVC_DATA_SUBJECT            "http://tizen.org/appcontrol/data/subject"
+/** APP_SVC DATA TYPE*/
+#define APPSVC_DATA_TO                 "http://tizen.org/appcontrol/data/to"
+/** APP_SVC DATA TYPE*/
+#define APPSVC_DATA_CC                 "http://tizen.org/appcontrol/data/cc"
+/** APP_SVC DATA TYPE*/
+#define APPSVC_DATA_BCC                        "http://tizen.org/appcontrol/data/bcc"
+/** APP_SVC DATA TYPE*/
+#define APPSVC_DATA_TEXT               "http://tizen.org/appcontrol/data/text"
+/** APP_SVC DATA TYPE*/
+#define APPSVC_DATA_TITLE              "http://tizen.org/appcontrol/data/title"
+/** APP_SVC DATA TYPE*/
+#define APPSVC_DATA_SELECTED           "http://tizen.org/appcontrol/data/selected"
+/** APP_SVC DATA TYPE*/
+#define APPSVC_DATA_KEYWORD            "http://tizen.org/appcontrol/data/keyword"
+
+/** APP SVC internal private key */
+#define APP_SVC_K_URI_R_INFO           "__APP_SVC_URI_R_INFO__"
+
+
+/**
+ * @brief Return values in appsvc. 
+ */
+typedef enum _appsvc_return_val {
+       APPSVC_RET_ELAUNCH = -4,                /**< Failure on launching the app */
+       APPSVC_RET_ENOMATCH = -3,               /**< No matching result Error */
+       APPSVC_RET_EINVAL = -2,                 /**< Invalid argument */
+       APPSVC_RET_ERROR = -1,                  /**< General error */
+       APPSVC_RET_OK = 0                       /**< General success */
+}appsvc_return_val;
+
+
+/**
+ * @brief result values in appsvc. 
+ */
+typedef enum _appsvc_result_val {
+       APPSVC_RES_CANCEL = -2,         /**< Cancel by system */
+       APPSVC_RES_NOT_OK = -1,         /**< Fail by user */
+       APPSVC_RES_OK = 0               /**< Success by user */
+}appsvc_result_val;
+
+
+/** 
+ * @brief appsvc_res_fn is appsvc result function
+ * @param[out] b               result bundle   
+ * @param[out] request_code    request code
+ * @param[out] result                  result value
+ * @param[out] data            user-supplied data      
+*/
+typedef void (*appsvc_res_fn)(bundle *b, int request_code, appsvc_result_val result, void *data);
+
+
+/** 
+ * @brief iterator function running with appsvc_get_list 
+ * @param[out] pkg_name        package name retreived by appsvc_get_list
+ * @param[out] data            user-supplied data      
+*/
+typedef int (*appsvc_info_iter_fn)(const char *appid, void *data);
+
+typedef int (*appsvc_host_res_fn)(void *data);
+
+/**
+ * @par Description:
+ * This function sets an operation to launch application based on appsvc.
+ *
+ * @param[in] b bundle object 
+ * @param[in] operation operation 
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error 
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks An application must call this function before using appsvc_run_service API. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+
+       b = bundle_create();
+       
+       appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
+}
+ * @endcode
+ *
+ */
+int appsvc_set_operation(bundle *b, const char *operation);
+
+/**
+ * @par Description:
+ * This function sets an uri to launch application based on appsvc.
+ *
+ * @param[in] b bundle object 
+ * @param[in] uri uri 
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error 
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+
+       b = bundle_create();
+       
+       appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
+       appsvc_set_uri(b,"http://www.samsung.com");
+}
+ * @endcode
+ *
+ */
+int appsvc_set_uri(bundle *b, const char *uri);
+
+/**
+ * @par Description:
+ * This function sets a mime-type to launch application based on appsvc.
+ *
+ * @param[in] b bundle object 
+ * @param[in] mime mime-type 
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error 
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+
+       b = bundle_create();
+       
+       appsvc_set_operation(b, APPSVC_OPERATION_PICK);
+       appsvc_set_mime(b,"image/jpg");
+}
+ * @endcode
+ *
+ */
+int appsvc_set_mime(bundle *b, const char *mime);
+
+/**
+ * @par Description:
+ * This function sets an extra data to launch application based on appsvc.
+ *
+ * @param[in] b bundle object 
+ * @param[in] key key of extra data 
+ * @param[in] val data 
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+
+       b = bundle_create();
+       
+       appsvc_set_operation(b, APPSVC_OPERATION_SEND);
+       appsvc_set_uri(b,"mailto:xxx1@xxx");
+       appsvc_add_data(b,APPSVC_DATA_CC,"xxx2@xxx");
+}
+ * @endcode
+ *
+ */
+int appsvc_add_data(bundle *b, const char *key, const char *val);
+
+/**
+ * @par Description:
+ * This function sets an extra array data to launch application based on appsvc.
+ *
+ * @param[in] b bundle object 
+ * @param[in] key key of extra data 
+ * @param[in] val_array data 
+ * @param[in] len Length of array
+ *
+ * @return 0 if success, negative value(<0) if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+       char *images[] = {"/opt/media/a.jpg", "/opt/media/b.jpg", "/opt/media/c.jpg"};
+
+       b = bundle_create();
+
+       appsvc_add_data_array(b, APPSVC_DATA_SELECTED, images, 3);
+}
+ * @endcode
+ *
+ */
+int appsvc_add_data_array(bundle *b, const char *key, const char **val_array, int len);
+
+
+/**
+ * @par Description:
+ * This function sets a package name to launch application based on appsvc.
+ *
+ * @param[in] b bundle object 
+ * @param[in] pkg_name package name for explict launch
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error 
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+
+       b = bundle_create();
+       
+       appsvc_set_operation(b, APPSVC_OPERATION_PICK);
+       appsvc_set_mime(b,"image/jpg");
+       appsvc_set_pkgname(b, "org.tizen.mygallery");
+}
+ * @endcode
+ *
+ */
+/* Deprecated API */
+int appsvc_set_pkgname(bundle *b, const char *pkg_name); // __attribute__((deprecated));
+
+
+/**
+ * @par Description:
+ * This function sets a appid to launch application based on appsvc.
+ *
+ * @param[in] b bundle object
+ * @param[in] appid application id for explict launch
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       appsvc_set_operation(b, APPSVC_OPERATION_PICK);
+       appsvc_set_mime(b,"image/jpg");
+       appsvc_set_appid(b, "org.tizen.mygallery");
+}
+ * @endcode
+ *
+ */
+int appsvc_set_appid(bundle *b, const char *appid);
+
+
+/**
+ * @par Description:
+ * This function sets a appid to launch application based on appsvc.
+ *
+ * @param[in] b bundle object
+ * @param[in] application category
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+
+       b = bundle_create();
+
+       appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
+       appsvc_set_category(b, "http://tizen.org/category/app/browser");
+}
+ * @endcode
+ *
+ */
+int appsvc_set_category(bundle *b, const char *category);
+
+/**
+ * @par Description:
+ * This API launch application based on appsvc.
+ *
+ * @param[in] b bundle to be passed to callee
+ * @param[in] request_code request code
+ * @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 callee's pid - success
+ * @retval APPSVC_RET_ERROR - general error 
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ * @retval APPSVC_RET_ENOMATCH - no matching result Error 
+ * @retval APPSVC_RET_ELAUNCH - failure on launching the app
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       bundle *b = NULL;
+       static int num = 0;
+
+       b = bundle_create();
+       
+       appsvc_set_operation(b, APPSVC_OPERATION_PICK);
+       appsvc_set_mime(b,"image/jpg");
+
+       return appsvc_run_service(b, 0, cb_func, (void*)NULL);
+}
+ * @endcode
+ *
+ */
+int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, void *data);
+
+/**
+ * @par Description:
+ * This API use to get application list that is matched with given bundle.
+ *
+ * @param[in] b bundle to resolve application
+ * @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 APPSVC_RET_OK - success
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ * @retval APPSVC_RET_ENOMATCH - no matching result Error 
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+static int iter_fn(const char* pkg_name, void *data)
+{
+       printf("\t==========================\n");
+       printf("\t pkg_name: %s\n", pkg_name);
+       printf("\t==========================\n");
+       return 0;
+}
+
+...
+{
+       bundle *b = NULL;
+       static int num = 0;
+
+       b = bundle_create();
+       
+       appsvc_set_operation(b, APPSVC_OPERATION_PICK);
+       appsvc_set_mime(b,"image/jpg");
+
+       return appsvc_get_list(b, iter_fn, (void*)NULL);
+}
+ * @endcode
+ *
+ */
+int appsvc_get_list(bundle *b, appsvc_info_iter_fn iter_fn, void *data);
+
+/**
+ * @par Description:
+ * This function gets a operation from bundle.
+ *
+ * @param[in] b bundle object 
+ *
+ * @return Pointer for operation string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       char *val;      
+       val = appsvc_get_operation(b);
+}
+ * @endcode
+ *
+ */
+const char *appsvc_get_operation(bundle *b);
+
+/**
+ * @par Description:
+ * This function gets a uri from bundle.
+ *
+ * @param[in] b bundle object 
+ *
+ * @return Pointer for uri string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       char *val;      
+       val = appsvc_get_uri(b);
+}
+ * @endcode
+ *
+ */
+const char *appsvc_get_uri(bundle *b);
+
+/**
+ * @par Description:
+ * This function gets a mime-type from bundle.
+ *
+ * @param[in] b bundle object 
+ *
+ * @return Pointer for mime-type string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       char *val;      
+       val = appsvc_get_mime(b);
+}
+ * @endcode
+ *
+ */
+const char *appsvc_get_mime(bundle *b);
+
+/**
+ * @par Description:
+ * This function gets a package name from bundle.
+ *
+ * @param[in] b bundle object 
+ *
+ * @return Pointer for package name string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       char *val;      
+       val = appsvc_get_pkgname(b);
+}
+ * @endcode
+ *
+ */
+/* Deprecated API */
+const char *appsvc_get_pkgname(bundle *b); // __attribute__((deprecated));
+
+/**
+ * @par Description:
+ * This function gets a application id from bundle.
+ *
+ * @param[in] b bundle object
+ *
+ * @return Pointer for application id string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       char *val;
+       val = appsvc_get_appid(b);
+}
+ * @endcode
+ *
+ */
+const char *appsvc_get_appid(bundle *b);
+
+/**
+ * @par Description:
+ * This function gets a application category from bundle.
+ *
+ * @param[in] b bundle object
+ *
+ * @return Pointer for application category string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       char *val;
+       val = appsvc_get_category(b);
+}
+ * @endcode
+ *
+ */
+const char *appsvc_get_category(bundle *b);
+
+/**
+ * @par Description:
+ * This function gets value from key.
+ *
+ * @param[in] b bundle object 
+ * @param[in] key key
+ *
+ * @return Pointer for value string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       char *val;      
+       val = appsvc_get_data(b, APPSVC_DATA_CC);
+}
+ * @endcode
+ *
+ */
+const char *appsvc_get_data(bundle *b, const char *key);
+
+/**
+ * @par Description:
+ * This function gets value from key.
+ *
+ * @param[in] b bundle object 
+ * @param[in] key key
+ * @param[out] len length of array
+ *
+ * @return Pointer for value string array if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       char **val_array;       
+       int len;
+       char *val;
+
+       if(appsvc_data_is_array(b, APPSVC_DATA_SELECTED))
+               val_array = appsvc_get_data_array(b, APPSVC_DATA_SELECTED, &len);
+       else 
+               val = appsvc_get_data(b, APPSVC_DATA_SELECTED);
+}
+ * @endcode
+ *
+ */
+const char **appsvc_get_data_array(bundle *b, const char *key, int *len);
+
+/**
+ * @par Description:
+ * This API create appsvc result bundle based on bundle received in reset event.
+ *
+ * @param[in] inb bundle received in reset event 
+ * @param[in] outb bundle to use for returning result 
+ *
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error 
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see appsvc_send_result.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       struct appdata *ad = data;
+       bundle* res_bundle;
+       
+       appsvc_create_result_bundle(ad->b,&res_bundle);
+       bundle_add(res_bundle, "result", "1");
+       appsvc_send_result(res_bundle, 0);
+}
+ * @endcode
+ *
+ */
+int appsvc_create_result_bundle(bundle *inb, bundle **outb);
+
+/**
+ * @par Description:
+ * This API send appsvc result to caller with bundle.
+ *
+ * @param[in] b Result data in bundle format
+ * @param[in] result result value
+ *
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error 
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre appsvc_create_result_bundle.
+ * @post None.
+ * @see appsvc_send_result.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       struct appdata *ad = data;
+       bundle* res_bundle;
+       
+       appsvc_create_result_bundle(ad->b,&res_bundle);
+       bundle_add(res_bundle, "result", "1");
+       appsvc_send_result(res_bundle, 0);
+}
+ * @endcode
+ *
+ */
+int appsvc_send_result(bundle *b, appsvc_result_val result);
+
+/**
+ * @par Description:
+ * This API set the default application(package name) associated with op, uri and mime-type.
+ *
+ * @param[in] op               operation
+ * @param[in] mime_type        mime-type
+ * @param[in] scheme   scheme of uri
+ * @param[in] defapp   default application
+ *
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error 
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       appsvc_set_defapp(APPSVC_OPERATION_VIEW, NULL,"http", "org.tizen.mybrowser");
+}
+ * @endcode
+ *
+ */
+int appsvc_set_defapp(const char *op, const char *mime_type, const char *uri,
+                               const char *defapp);
+
+/**
+ * @par Description:
+ * This API unset the default application(package name) associated with op, uri and mime-type.
+ *
+ * @param[in] defapp   default application
+ *
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error 
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None. 
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       appsvc_unset_defapp("org.tizen.test");
+}
+ * @endcode
+ *
+ */
+int appsvc_unset_defapp(const char *defapp);
+
+/**
+ * @par Description:
+ *     This API ask a application is default application or not.
+ *
+ * @param[in]  pkg_name        application package name
+ * @return     true / false
+ * @retval     1       app_name is default application in appsvc.
+ * @retval     0       app_name is NOT default application in appsvc.
+ *
+  * @pre None.
+  * @post None.
+  * @see None.
+  * @remarks None. 
+  *
+  * @par Sample code:
+  * @code
+#include <appsvc.h>
+ ...
+
+ * int is_defapp_browser_app()
+ * { 
+ *      return appsvc_is_defapp("org.tizen.browser");
+ * }
+ *
+ * @endcode
+ * @remark
+ *     None
+* 
+*/
+int appsvc_is_defapp(const char *appid);
+
+
+/**
+ * @par Description:
+ *     This API ask a extra data is array or not.
+ *
+ * @param[in] b bundle object 
+ * @param[in] key key of extra data 
+ * @return     true / false
+ * @retval     1       a extra data is array.
+ * @retval     0       a extra data is not array.
+ *
+  * @pre None.
+  * @post None.
+  * @see None.
+  * @remarks None. 
+  *
+  * @par Sample code:
+  * @code
+#include <appsvc.h>
+ ...
+
+ * int is_defapp_browser_app(bundle *b, char *key)
+ * { 
+ *      return appsvc_data_is_array(b, key);
+ * }
+ *
+ * @endcode
+ * @remark
+ *     None
+* 
+*/
+int appsvc_data_is_array(bundle *b, const char *key);
+
+
+#ifdef __cplusplus
+       }
+#endif
+
+/**
+ * @}
+ */
+/**
+ * @}
+ */
+
+
+#endif         /* __APP_SVC_H__ */
+
+/* vi: set ts=8 sts=8 sw=8: */
diff --git a/include/appsvc_db.h b/include/appsvc_db.h
new file mode 100755 (executable)
index 0000000..b9ef5c8
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ *  app-svc
+ *
+ * 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_SVC_DB_H__
+#define __APP_SVC_DB_H__
+
+#include <sqlite3.h>
+#include <time.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+int _svc_db_add_app(const char *op, const char *mime_type, const char *uri, const char *pkg_name);
+int _svc_db_delete_with_pkgname(const char *pkg_name);
+char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri);
+int _svc_db_is_defapp(const char *pkg_name);
+int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pkg_list);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif         /* __APP_SVC_DB_H__ */
+
diff --git a/include/internal.h b/include/internal.h
new file mode 100755 (executable)
index 0000000..b255ea3
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ *  app-svc
+ *
+ * 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 __INTERNAL_H__
+#define __INTERNAL_H__
+
+#include <unistd.h>
+#include <ctype.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "APP_SVC"
+
+#define MAX_FILTER_STR_SIZE 1024
+#define MAX_PACKAGE_STR_SIZE 512
+#define MAX_URI_STR_SIZE 256
+#define MAX_MIME_STR_SIZE 256
+#define MAX_SCHEME_STR_SIZE 256
+#define MAX_HOST_STR_SIZE 256
+#define MAX_OP_STR_SIZE 128
+#define MAX_LOCAL_BUFSZ 128
+
+#define _E(fmt, arg...) LOGE(fmt,##arg)
+#define _D(fmt, arg...) LOGD(fmt,##arg)
+
+#define retvm_if(expr, val, fmt, arg...) do { \
+       if(expr) { \
+               _E(fmt, ##arg); \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#define retv_if(expr, val) do { \
+       if(expr) { \
+               _E("(%s) -> %s() return", #expr, __FUNCTION__); \
+               return (val); \
+       } \
+} while (0)
+
+#endif /* __INTERNAL_H__ */
+
diff --git a/include/priv_key.h b/include/priv_key.h
new file mode 100755 (executable)
index 0000000..71ab27d
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ *  app-svc
+ *
+ * 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 __PRIV_KEY_H__
+#define __PRIV_KEY_H__
+
+
+/** APP SVC internal private key */
+#define APP_SVC_K_OPERATION    "__APP_SVC_OP_TYPE__"
+/** APP SVC internal private key */
+#define APP_SVC_K_URI          "__APP_SVC_URI__"
+/** APP SVC internal private key */
+#define APP_SVC_K_MIME         "__APP_SVC_MIME_TYPE__"
+/** APP SVC internal private key */
+#define APP_SVC_K_DATA         "__APP_SVC_DATA__"
+/** APP SVC internal private key */
+#define APP_SVC_K_PKG_NAME     "__APP_SVC_PKG_NAME__"
+/** APP SVC internal private key */
+#define APP_SVC_K_CATEGORY     "__APP_SVC_CATEGORY__"
+/** APP SVC internal private key */
+#define APP_SVC_K_RES_VAL      "__APP_SVC_K_RES_VAL__"
+
+/** APP SVC internal private key */
+#define APP_SVC_K_WIN_ID       "__APP_SVC_K_WIN_ID__"
+
+
+#endif         /* __PRIV_KEY_H__ */
+
+/* vi: set ts=8 sts=8 sw=8: */
diff --git a/packaging/app-svc.spec b/packaging/app-svc.spec
new file mode 100644 (file)
index 0000000..ab21033
--- /dev/null
@@ -0,0 +1,86 @@
+#sbs-git:slp/pkgs/a/app-svc app-svc 0.1.19 de68cdc468eaded317b4f5be9cdafebb01639aa0
+Name:      app-svc
+Summary:    App svc
+Version: 0.1.42
+Release:    1
+Group:      System/Libraries
+License:    Apache License, Version 2.0
+Source0:    %{name}-%{version}.tar.gz
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+
+BuildRequires: cmake
+
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(ecore) 
+BuildRequires: pkgconfig(x11)
+BuildRequires: pkgconfig(libprivilege-control)
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(dbus-glib-1)
+BuildRequires: pkgconfig(ail)
+BuildRequires: pkgconfig(xdgmime)
+BuildRequires: pkgconfig(aul)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(libsoup-2.4)
+BuildRequires: pkgconfig(iniparser)
+BuildRequires: pkgconfig(pkgmgr-info)
+
+
+%description
+App svc
+
+%package devel
+Summary:    App svc
+Group:      Development/Libraries
+Requires:   %{name} = %{version}-%{release}
+%description devel
+App svc (developement files)
+
+%prep
+%setup -q
+
+
+%build
+
+CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=/usr
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+
+%post
+
+/sbin/ldconfig
+mkdir -p /opt/dbspace
+sqlite3 /opt/dbspace/.appsvc.db < /opt/share/appsvc_db.sql
+rm -rf /opt/share/appsvc_db.sql
+
+chown 0:5000 /opt/dbspace/.appsvc.db
+chown 0:5000 /opt/dbspace/.appsvc.db-journal
+chmod 664 /opt/dbspace/.appsvc.db
+chmod 664 /opt/dbspace/.appsvc.db-journal
+chsmack -a 'app-svc::db' /opt/dbspace/.appsvc.db
+chsmack -a 'app-svc::db' /opt/dbspace/.appsvc.db-journal
+
+%postun -p /sbin/ldconfig
+
+%files
+%manifest app-svc.manifest
+%defattr(-,root,root,-)
+/opt/share/appsvc_db.sql
+/usr/bin/appsvc_test
+/usr/lib/libappsvc.so.0
+/usr/lib/libappsvc.so.0.1.0
+
+%files devel
+%defattr(-,root,root,-)
+/usr/lib/pkgconfig/appsvc.pc
+/usr/lib/libappsvc.so
+/usr/include/appsvc/appsvc.h
+
+
diff --git a/src/appsvc.c b/src/appsvc.c
new file mode 100755 (executable)
index 0000000..db1d4da
--- /dev/null
@@ -0,0 +1,1016 @@
+/*
+ *  app-svc
+ *
+ * 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 <glib.h>
+#include <string.h>
+
+#include <ail.h>
+#include <aul.h>
+#include <libsoup/soup.h>
+#include <Ecore_X.h>
+#include <Ecore.h>
+#include <iniparser.h>
+#include <pkgmgr-info.h>
+
+#include "appsvc.h"
+#include "appsvc_db.h"
+#include "internal.h"
+#include "priv_key.h"
+
+
+
+
+#define APP_SELECTOR "org.tizen.app-selector"
+
+#ifndef SLPAPI
+#define SLPAPI __attribute__ ((visibility("default")))
+#endif
+
+
+/* callback handling */
+typedef struct _appsvc_cb_info_t{
+       appsvc_res_fn cb_func;
+       int request_code;
+       void *data;
+}appsvc_cb_info_t;
+
+typedef struct _appsvc_resolve_info_t{
+       char *pkgname;
+       char *op;
+       char *uri;
+       char *scheme;
+       char *host;
+       char *uri_r_info;
+       char *origin_mime;
+       char *mime;     
+       char *m_type;
+       char *s_type;
+       char *category;
+       int mime_set;
+}appsvc_resolve_info_t;
+
+extern int aul_launch_app_with_result(const char *pkgname, bundle *kb,
+                              void (*cbfunc) (bundle *, int, void *),
+                              void *data);
+
+static appsvc_cb_info_t *__create_rescb(int request_code, appsvc_res_fn cbfunc,
+                                       void *data);
+static void __remove_rescb(appsvc_cb_info_t *info);
+static int __set_bundle(bundle *b, const char *key, const char *value);
+static void __aul_cb(bundle *b, int is_cancel, void *data);
+static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code,
+                                 appsvc_res_fn cbfunc, void *data);
+static int __get_resolve_info(bundle *b, appsvc_resolve_info_t *info);
+static int __free_resolve_info_data(appsvc_resolve_info_t *info);
+static ail_cb_ret_e __ail_iter_func(const ail_appinfo_h appinfo,
+                                   void *user_data);
+static int __get_list_with_condition(char *op, char *uri,
+                                    char *mime, GSList **pkg_list);
+
+
+static appsvc_cb_info_t *__create_rescb(int request_code, appsvc_res_fn cbfunc, void *data)
+{
+       appsvc_cb_info_t* info;
+
+       info = (appsvc_cb_info_t*)calloc(1, sizeof(appsvc_cb_info_t));
+       if(info == NULL)
+               return NULL;
+
+       info->request_code = request_code;
+       info->cb_func = cbfunc;
+       info->data = data;
+
+       return info;
+}
+
+static void __remove_rescb(appsvc_cb_info_t *info)
+{
+       if(info) free(info);
+}
+
+static int __set_bundle(bundle *b, const char *key, const char *value)
+{
+       const char *val = NULL;
+
+       val = bundle_get_val(b, key);
+       if(val){
+               if( bundle_del(b, key) != 0 ){
+                       return APPSVC_RET_ERROR;
+               }
+       }
+
+       if(!value) 
+               return APPSVC_RET_EINVAL;
+               
+       if( bundle_add(b, key, value) != 0 ){
+               return APPSVC_RET_ERROR;
+       }
+
+       _D("__set_bundle");
+//     bundle_iterate(b, __bundle_iterate, NULL);
+
+       return APPSVC_RET_OK;
+}
+
+static int __set_bundle_array(bundle *b, const char *key, const char **value, int len)
+{
+
+       int type;
+       type = appsvc_data_is_array(b, key);
+
+       if(type == 1) {
+               if( bundle_del(b, key) != 0 ){
+                       return APPSVC_RET_ERROR;
+               }
+       }
+
+       if(!value) 
+               return APPSVC_RET_EINVAL;
+
+       if( bundle_add_str_array(b, key, value, len) != 0 ){
+               return APPSVC_RET_ERROR;
+       }
+
+       _D("__set_bundle_array");
+//     bundle_iterate(b, __bundle_iterate, NULL);
+
+       return APPSVC_RET_OK;
+}
+
+
+static void __aul_cb(bundle *b, int is_cancel, void *data)
+{
+       const char *val = NULL;
+       appsvc_cb_info_t*  cb_info;
+       int res;
+
+       if(is_cancel)
+               res = APPSVC_RES_CANCEL;
+       else{
+               /* get result_code from bundle */
+               val = bundle_get_val(b, APP_SVC_K_RES_VAL);
+               res = (val==NULL)? APPSVC_RES_NOT_OK : atoi(val);
+       }
+
+       /* remove result_code from bundle */
+       bundle_del(b, APP_SVC_K_RES_VAL);
+
+       /* find corresponding callback */
+       cb_info = (appsvc_cb_info_t*)data;
+       
+       cb_info->cb_func(b, cb_info->request_code, (appsvc_result_val)res, cb_info->data);
+       __remove_rescb(cb_info);
+       
+
+       return;
+}
+
+static int __run_svc_with_pkgname(char *pkgname, bundle *b, int request_code, appsvc_res_fn cbfunc, void *data)
+{
+       appsvc_cb_info_t *cb_info = NULL;
+       int ret = -1;
+       
+       if (cbfunc) {
+               _D("pkg_name : %s - with result", pkgname);
+
+               cb_info = __create_rescb(request_code, cbfunc, data);
+               ret = aul_launch_app_with_result(pkgname, b, __aul_cb, cb_info);
+               if(ret < 0)
+                       ret = APPSVC_RET_ELAUNCH;
+       } else {
+               _D("pkg_name : %s - no result", pkgname);
+               ret = aul_launch_app(pkgname, b);
+               if(ret < 0)
+                       ret = APPSVC_RET_ELAUNCH;
+       }
+
+       return ret;
+}
+
+static int __get_resolve_info(bundle *b, appsvc_resolve_info_t *info)
+{
+       char *tmp = NULL;
+       char *strtok_buf = NULL;
+       SoupURI *s_uri;
+       
+       info->op = (char *)appsvc_get_operation(b);
+       info->uri = (char *)appsvc_get_uri(b);
+       info->origin_mime = info->mime = (char *)appsvc_get_mime(b);
+       info->pkgname = (char *)appsvc_get_pkgname(b);
+       info->category = (char *)appsvc_get_category(b);
+
+       if(info->uri) {
+               if(strncmp(info->uri,"/",1) == 0){
+                       if(!info->mime) {
+                               info->mime = malloc(MAX_MIME_STR_SIZE);
+                               aul_get_mime_from_file(info->uri, info->mime, MAX_MIME_STR_SIZE);
+                               info->mime_set = 1;
+                       }
+                       info->uri = NULL;                       
+               } else if(strncmp(info->uri,"file:/",6)==0){
+                       if(!info->mime) {
+                               info->mime = malloc(MAX_MIME_STR_SIZE);
+                               aul_get_mime_from_file(&info->uri[5], info->mime, MAX_MIME_STR_SIZE);
+                               info->mime_set = 1;
+                       }
+                       info->uri = NULL;
+               } else if(strncmp(info->uri,"file:///",8) == 0){
+                       if(!info->mime) {
+                               info->mime = malloc(MAX_MIME_STR_SIZE);
+                               aul_get_mime_from_file(&info->uri[7], info->mime, MAX_MIME_STR_SIZE);   
+                               info->mime_set = 1;
+                       }
+                       info->uri = NULL;
+               }
+       }
+
+       if(info->uri) {
+               s_uri = soup_uri_new(info->uri);
+
+               if(!s_uri)
+                       return APPSVC_RET_EINVAL;
+
+               if(s_uri->scheme) {
+                       info->scheme = malloc(MAX_SCHEME_STR_SIZE);
+                       strncpy(info->scheme, s_uri->scheme, MAX_SCHEME_STR_SIZE-1);
+               }
+               if(s_uri->host) {
+                       info->host = malloc(MAX_HOST_STR_SIZE);
+                       strncpy(info->host, s_uri->host, MAX_HOST_STR_SIZE-1);
+               }
+               if(info->scheme && info->host) {
+                       info->uri_r_info = malloc(MAX_SCHEME_STR_SIZE+MAX_HOST_STR_SIZE+2);
+                       snprintf(info->uri_r_info, MAX_SCHEME_STR_SIZE+MAX_HOST_STR_SIZE+1,
+                               "%s://%s", info->scheme, info->host);
+               }
+
+               soup_uri_free(s_uri);
+       } else {
+               info->scheme = strdup("NULL");
+       }
+
+       if(!info->mime) 
+               info->mime = strdup("NULL");
+       else {
+               info->m_type = malloc(MAX_LOCAL_BUFSZ);
+               info->s_type = malloc(MAX_LOCAL_BUFSZ);
+               tmp = strdup(info->mime);
+               strtok_buf = strtok(tmp,"/");
+               if(strtok_buf)
+                       strncpy(info->m_type, strtok_buf, MAX_LOCAL_BUFSZ-1);
+               strtok_buf = strtok(NULL,"/");
+               if(strtok_buf)
+                       strncpy(info->s_type, strtok_buf, MAX_LOCAL_BUFSZ-1);
+               free(tmp);
+
+               if(strncmp(info->m_type, "*", 1) == 0) {
+                       strncpy(info->m_type, "%", MAX_LOCAL_BUFSZ-1);
+               }
+               if(strncmp(info->s_type, "*", 1) == 0) {
+                       strncpy(info->s_type, "%", MAX_LOCAL_BUFSZ-1);  
+               }
+
+               if(!info->mime_set)
+                       info->mime = malloc(MAX_MIME_STR_SIZE);
+               snprintf(info->mime, MAX_MIME_STR_SIZE-1, "%s/%s", info->m_type, info->s_type);
+       }
+
+       return 0;
+}
+
+static int __free_resolve_info_data(appsvc_resolve_info_t *info)
+{
+       if (info->mime) 
+               free(info->mime);
+       if (info->scheme) 
+               free(info->scheme);
+       if (info->host)
+               free(info->host);
+       if (info->m_type)
+               free(info->m_type);
+       if (info->s_type)
+               free(info->s_type);
+       if (info->uri_r_info)
+               free(info->uri_r_info);
+       
+       return 0;
+}
+
+static ail_cb_ret_e __ail_iter_func(
+                       const ail_appinfo_h appinfo, void *user_data)
+{
+       GSList **pkg_list = (GSList **)user_data;
+       GSList *iter = NULL;
+       char *str = NULL;
+       char *pkgname = NULL;
+
+       ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &str);
+
+       _D("Matching application is %s",str);
+
+       for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+               pkgname = (char *)iter->data;
+               if (strncmp(str, pkgname, MAX_PACKAGE_STR_SIZE-1) == 0)
+                       return AIL_CB_RET_CONTINUE;
+       }
+
+       pkgname = strdup(str);
+       *pkg_list = g_slist_append(*pkg_list, (void *)pkgname);
+       _D("%s is added",pkgname);
+
+       return AIL_CB_RET_CONTINUE;
+}
+
+static int __get_list_with_condition(char *op, char *uri, char *mime, GSList **pkg_list)
+{
+       ail_filter_h filter;
+       ail_error_e ail_ret;
+       char svc_filter[MAX_FILTER_STR_SIZE] = {0,};
+       
+       ail_ret = ail_filter_new(&filter);
+       if (ail_ret != AIL_ERROR_OK) 
+               return APPSVC_RET_ERROR;
+
+       snprintf(svc_filter, MAX_FILTER_STR_SIZE-1, "%s|%s|%s", op, uri, mime);
+       _D("svc_filter : %s",svc_filter);
+
+       ail_ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_SVC_STR, svc_filter);
+       if (ail_ret != AIL_ERROR_OK) {
+               ail_filter_destroy(filter);
+               return APPSVC_RET_ERROR;
+       }
+
+       ail_filter_list_appinfo_foreach(filter, __ail_iter_func, (void *)pkg_list);
+
+       ail_filter_destroy(filter);
+
+       return APPSVC_RET_OK;
+}
+
+SLPAPI int appsvc_set_operation(bundle *b, const char *operation)
+{      
+       if(b == NULL){
+               _E("bundle for appsvc_set_operation is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+
+       return __set_bundle(b, APP_SVC_K_OPERATION, operation);
+}
+
+SLPAPI int appsvc_set_uri(bundle *b, const char *uri)
+{      
+       if(b == NULL){
+               _E("bundle for appsvc_set_uri is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+       
+       return __set_bundle(b, APP_SVC_K_URI, uri);
+}
+
+SLPAPI int appsvc_set_mime(bundle *b, const char *mime)
+{      
+       if(b == NULL){
+               _E("bundle for appsvc_set_mime is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+
+       return __set_bundle(b, APP_SVC_K_MIME, mime);
+}
+
+SLPAPI int appsvc_add_data(bundle *b, const char *key, const char *val)
+{
+       if(b == NULL || key == NULL) {
+               return APPSVC_RET_EINVAL;
+       }
+
+       /* check key for data */
+       /******************/
+
+       return __set_bundle(b, key, val);
+}
+
+SLPAPI int appsvc_add_data_array(bundle *b, const char *key,  const char **val_array, int len)
+{
+       if(b == NULL || key == NULL) {
+               return APPSVC_RET_EINVAL;
+       }
+
+       /* check key for data */
+       /******************/
+
+       return __set_bundle_array(b, key, val_array, len);
+}
+
+
+SLPAPI int appsvc_set_pkgname(bundle *b, const char *pkg_name)
+{      
+       if(b == NULL){
+               _E("bundle for appsvc_set_pkgname is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+
+       return __set_bundle(b, APP_SVC_K_PKG_NAME, pkg_name);
+}
+
+static char* __get_alias_appid(char *appid)
+{
+       char *alias_id = NULL;
+       char *val = NULL;
+       char key_string[MAX_PACKAGE_STR_SIZE+5];
+       dictionary *dic;
+
+       dic = iniparser_load("/usr/share/appsvc/alias.ini");
+
+       if(dic == NULL)
+               return NULL;
+
+       sprintf(key_string, "Alias:%s", appid);
+       val = iniparser_getstr(dic, key_string);
+
+       _D("alias_id : %s", val);
+
+       if(val != NULL) {
+               alias_id = malloc(MAX_PACKAGE_STR_SIZE);
+               strncpy(alias_id, val, MAX_PACKAGE_STR_SIZE-1);
+       }
+
+       iniparser_freedict(dic);
+
+       return alias_id;
+}
+
+SLPAPI int appsvc_set_appid(bundle *b, const char *appid)
+{
+       char *alias_id = NULL;
+       int ret;
+
+       if(b == NULL || appid == NULL){
+               _E("bundle for appsvc_set_appid is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+
+       alias_id = __get_alias_appid(appid);
+       if(alias_id == NULL) {
+               ret = __set_bundle(b, APP_SVC_K_PKG_NAME, appid);
+       } else {
+               ret = __set_bundle(b, APP_SVC_K_PKG_NAME, alias_id);
+               free(alias_id);
+       }
+
+       return ret;
+}
+
+SLPAPI int appsvc_set_category(bundle *b, const char *category)
+{
+       if(b == NULL){
+               _E("bundle for appsvc_set_category is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+
+       return __set_bundle(b, APP_SVC_K_CATEGORY, category);
+}
+
+static int __get_list_with_condition_mime_extened(char *op, char *uri, char *mime,
+       char *m_type, char *s_type, GSList **pkg_list)
+{
+       char *tmp;
+
+       tmp = malloc(MAX_MIME_STR_SIZE);
+
+       __get_list_with_condition(op, uri, mime, pkg_list);
+
+       if ((strncmp(mime, "NULL", 4) != 0) && (strncmp(s_type, "%", 1) != 0)) {
+               snprintf(tmp, MAX_MIME_STR_SIZE-1, "%s/*", m_type);
+               __get_list_with_condition(op, uri, tmp, pkg_list);
+       }
+
+       if ((strncmp(mime, "NULL", 4) != 0) && (strncmp(m_type, "%", 1) != 0)) {
+               snprintf(tmp, MAX_MIME_STR_SIZE-1, "*/*");
+               __get_list_with_condition(op, uri, tmp, pkg_list);
+       }
+
+       free(tmp);
+
+       return 0;
+}
+
+static int __get_list_with_condition_mime_extened_with_collation(char *op, char *uri, char *mime,
+       char *m_type, char *s_type, GSList **pkg_list)
+{
+       _svc_db_get_list_with_collation(op, uri, mime, pkg_list);
+
+       return 0;
+}
+
+GSList *tmp_list;
+static int __app_list_cb(pkgmgrinfo_appinfo_h handle, void *user_data)
+{
+       char *appid = NULL;
+       GSList **app_list = (GSList **)user_data;
+       char *str = NULL;
+       GSList *iter = NULL;
+
+       pkgmgrinfo_appinfo_get_appid(handle, &str);
+       _D("Matching application is %s",str);
+
+       for (iter = tmp_list; iter != NULL; iter = g_slist_next(iter)) {
+               if (strncmp(str, (char *)iter->data, MAX_PACKAGE_STR_SIZE-1) == 0) {
+                       appid = strdup(str);
+                       *app_list = g_slist_append(*app_list, (void *)appid);
+                       _D("%s is added",appid);
+               }
+       }
+
+       return 0;
+}
+
+static int __get_list_with_category(char *category, GSList **pkg_list)
+{
+       int ret;
+       pkgmgrinfo_appinfo_filter_h handle;
+       GSList *app_list = NULL;
+       GSList *iter = NULL;
+       char *list_item = NULL;
+       int match;
+
+       ret = pkgmgrinfo_appinfo_filter_create(&handle);
+       ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, category);
+
+       tmp_list = *pkg_list;
+       ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __app_list_cb, &app_list);
+       if (ret != PMINFO_R_OK) {
+               pkgmgrinfo_appinfo_filter_destroy(handle);
+               return -1;
+       }
+       pkgmgrinfo_appinfo_filter_destroy(handle);
+
+       for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+               list_item = (char *)iter->data;
+               g_free(list_item);
+       }
+       g_slist_free(*pkg_list);
+
+       *pkg_list = app_list;
+
+       return 0;
+}
+
+SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, void *data)
+{
+       appsvc_resolve_info_t info;
+       char *pkgname;
+       int pkg_count = 0;
+       int ret = -1;
+
+       GSList *pkg_list = NULL;
+       GSList *iter = NULL;
+       char *list_item;
+
+       if(b == NULL){
+               _E("bundle for appsvc_set_appid is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+
+       memset(&info, 0, sizeof(appsvc_resolve_info_t));
+       ret = __get_resolve_info(b, &info);
+       if(ret < 0)
+               return ret;
+
+       pkgname = info.pkgname;
+       _D("op - %s / mime - %s / shceme - %s\n", info.op, info.origin_mime, info.scheme);
+
+       /* explict*/
+       if(pkgname) {
+               if(appsvc_get_operation(b) == NULL)
+                       appsvc_set_operation(b,APPSVC_OPERATION_DEFAULT);
+               ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+               __free_resolve_info_data(&info);
+               return ret;
+       }
+
+       /*uri*/
+       pkgname = _svc_db_get_app(info.op, info.origin_mime, info.uri);
+       if(pkgname==NULL){
+               __get_list_with_condition_mime_extened_with_collation(info.op, info.uri,
+                               info.mime, info.m_type, info.s_type, &pkg_list);
+               pkg_count = g_slist_length(pkg_list);
+               if(pkg_count > 0) {
+
+                       if(info.uri_r_info) {
+                               __get_list_with_condition_mime_extened(info.op, info.uri_r_info,
+                                       info.mime, info.m_type, info.s_type, &pkg_list);
+                       }
+
+                       __get_list_with_condition_mime_extened(info.op, info.scheme,
+                               info.mime, info.m_type, info.s_type, &pkg_list);
+
+                       if(info.category) {
+                               __get_list_with_category(info.category, &pkg_list);
+                       }
+
+                       pkg_count = g_slist_length(pkg_list);
+                       _D("pkg_count : %d", pkg_count);
+
+                       if(pkg_count == 1){
+                               pkgname = (char *)pkg_list->data;
+                               if(pkgname != NULL){
+                                       ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+                                       goto end;
+                               }
+                       } else {
+                               bundle_add(b, APP_SVC_K_URI_R_INFO, info.uri);
+                               ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code, cbfunc, data);
+                               goto end;
+                       }
+                       for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+                               list_item = (char *)iter->data;
+                               g_free(list_item);
+                       }
+                       g_slist_free(pkg_list);
+                       pkg_list = NULL;
+               }
+       } else {
+               ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+               free(pkgname);
+               goto end;
+       }
+
+       /*scheme & host*/
+       if(info.uri_r_info) {
+               pkgname = _svc_db_get_app(info.op, info.origin_mime, info.uri_r_info);
+
+               if(pkgname==NULL){
+                       __get_list_with_condition_mime_extened(info.op, info.uri_r_info,
+                               info.mime, info.m_type, info.s_type, &pkg_list);
+                       pkg_count = g_slist_length(pkg_list);
+                       if(pkg_count > 0) {
+                               __get_list_with_condition_mime_extened(info.op, info.scheme,
+                                       info.mime, info.m_type, info.s_type, &pkg_list);
+
+                               if(info.category) {
+                                       __get_list_with_category(info.category, &pkg_list);
+                               }
+
+                               pkg_count = g_slist_length(pkg_list);
+                               _D("pkg_count : %d", pkg_count);
+
+                               if(pkg_count == 1){
+                                       pkgname = (char *)pkg_list->data;
+                                       if(pkgname != NULL){
+                                               ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+                                               goto end;
+                                       }
+                               } else {
+                                       bundle_add(b, APP_SVC_K_URI_R_INFO, info.uri_r_info);
+                                       ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code, cbfunc, data);
+                                       goto end;
+                               }
+                       }
+                       for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+                               list_item = (char *)iter->data;
+                               g_free(list_item);
+                       }
+                       g_slist_free(pkg_list);
+                       pkg_list = NULL;
+               }  else {
+                       ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+                       free(pkgname);
+                       goto end;
+               }
+       }
+
+       /*scheme*/
+       pkgname = _svc_db_get_app(info.op, info.origin_mime, info.scheme);
+
+       if(pkgname==NULL){
+               __get_list_with_condition_mime_extened(info.op, info.scheme,
+                       info.mime, info.m_type, info.s_type, &pkg_list);
+
+               if(info.category) {
+                       __get_list_with_category(info.category, &pkg_list);
+               }
+
+               pkg_count = g_slist_length(pkg_list);
+               _D("pkg_count : %d", pkg_count);
+
+               if(pkg_count == 1){
+                       pkgname = (char *)pkg_list->data;
+                       if(pkgname != NULL){
+                               ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+                       }
+               } else if(pkg_count < 1) {
+                       __free_resolve_info_data(&info);
+                       return APPSVC_RET_ENOMATCH;
+               } else {
+                       bundle_add(b, APP_SVC_K_URI_R_INFO, info.scheme);
+                       ret = __run_svc_with_pkgname(APP_SELECTOR, b, request_code, cbfunc, data);
+               }
+
+               for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+                       list_item = (char *)iter->data;
+                       g_free(list_item);
+               }
+               g_slist_free(pkg_list); 
+       } else {
+               ret = __run_svc_with_pkgname(pkgname, b, request_code, cbfunc, data);
+               free(pkgname);
+       }
+
+end:
+       __free_resolve_info_data(&info);
+
+       return ret;
+}
+
+SLPAPI int appsvc_get_list(bundle *b, appsvc_info_iter_fn iter_fn, void *data)
+{
+       appsvc_resolve_info_t info;
+       char *pkgname = NULL;
+       int pkg_count;
+       int ret = -1;
+
+       GSList *pkg_list = NULL;
+       GSList *iter = NULL;
+
+       if(b == NULL){
+               _E("bundle for appsvc_run_service is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+       
+       if (iter_fn == NULL){
+               _E("iter_fn for appsvc_run_service is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+       
+       /* parse bundle */
+       memset(&info, 0, sizeof(appsvc_resolve_info_t));
+       ret = __get_resolve_info(b,&info);
+       if(ret < 0)
+               return ret;
+       
+       _D("operation - %s / shceme - %s / mime - %s\n", info.op, info.scheme, info.mime);
+
+       __get_list_with_condition_mime_extened_with_collation(info.op, info.uri,
+                       info.mime, info.m_type, info.s_type, &pkg_list);
+
+       if(info.uri_r_info) {
+               __get_list_with_condition_mime_extened(info.op, info.uri_r_info, 
+                       info.mime, info.m_type, info.s_type, &pkg_list);
+       }
+       
+       __get_list_with_condition_mime_extened(info.op, info.scheme, 
+               info.mime, info.m_type, info.s_type, &pkg_list);
+
+       if(info.category) {
+               __get_list_with_category(info.category, &pkg_list);
+       }
+
+       pkg_count = g_slist_length(pkg_list);
+       if (pkg_count == 0) {
+               _E("Cannot find associated application");
+               return APPSVC_RET_ENOMATCH;
+       }
+
+       for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+               pkgname = iter->data;
+               _D("PKGNAME : %s\n", pkgname);
+               if( iter_fn(pkgname,data) != 0)
+                       break;
+               g_free(pkgname);
+       }
+
+       g_slist_free(pkg_list);
+       __free_resolve_info_data(&info);
+
+       return APPSVC_RET_OK;   
+}
+
+SLPAPI const char *appsvc_get_operation(bundle *b)
+{
+       return bundle_get_val(b, APP_SVC_K_OPERATION);
+}
+
+SLPAPI const char *appsvc_get_uri(bundle *b)
+{
+       return bundle_get_val(b, APP_SVC_K_URI);
+}
+
+SLPAPI const char *appsvc_get_mime(bundle *b)
+{
+       return bundle_get_val(b, APP_SVC_K_MIME);
+}
+
+SLPAPI const char *appsvc_get_data(bundle *b, const char *key)
+{
+       return bundle_get_val(b, key);
+}
+
+SLPAPI const char **appsvc_get_data_array(bundle *b, const char *key, int *len)
+{
+       return bundle_get_str_array(b, key, len);
+}
+
+SLPAPI const char *appsvc_get_pkgname(bundle *b)
+{
+       return bundle_get_val(b, APP_SVC_K_PKG_NAME);
+}
+
+SLPAPI const char *appsvc_get_appid(bundle *b)
+{
+       return bundle_get_val(b, APP_SVC_K_PKG_NAME);
+}
+
+SLPAPI const char *appsvc_get_category(bundle *b)
+{
+       return bundle_get_val(b, APP_SVC_K_CATEGORY);
+}
+
+SLPAPI int appsvc_create_result_bundle(bundle *inb, bundle **outb)
+{
+       int ret = -1;
+
+       if(inb == NULL || outb == NULL) {
+               _E("bundle is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+       
+       ret = aul_create_result_bundle(inb, outb);
+
+       /* add additional bundle */
+       /*      bundle_add(outb, " ", " ");  */
+
+       if(ret == AUL_R_OK)
+               ret = APPSVC_RET_OK;
+       else if(ret == AUL_R_EINVAL)
+               ret = APPSVC_RET_EINVAL;
+       else
+               ret = APPSVC_RET_ERROR;
+
+       return ret;
+}
+
+SLPAPI int appsvc_send_result(bundle *b, appsvc_result_val result)
+{
+       int ret;
+       char tmp[MAX_LOCAL_BUFSZ];
+       
+       if(b == NULL){
+               _E("appsvc_send_result is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+
+       if(result != APPSVC_RES_OK && result != APPSVC_RES_NOT_OK){
+               _E("invalid result %d", (int)result);
+               return APPSVC_RET_EINVAL;
+       }
+
+       /* add result_code to bundle */
+       snprintf(tmp,MAX_LOCAL_BUFSZ,"%d", (int)result);
+       ret = __set_bundle(b, APP_SVC_K_RES_VAL, tmp);
+       if(ret < 0)
+               return APPSVC_RET_ERROR;
+
+       ret = aul_send_service_result(b);
+
+       /* remove result_code from bundle */
+       bundle_del(b, APP_SVC_K_RES_VAL);
+
+       return ret;
+} 
+
+SLPAPI int appsvc_set_defapp(const char *op, const char *mime_type, const char *uri,
+                                       const char *defapp)
+{
+       int ret;
+
+       if(op == NULL || defapp == NULL)
+               return APPSVC_RET_EINVAL;
+
+       ret = _svc_db_add_app(op, mime_type, uri, defapp);
+
+       if(ret < 0)
+               return APPSVC_RET_ERROR;
+       
+       return APPSVC_RET_OK;
+}
+
+SLPAPI int appsvc_unset_defapp(const char *defapp)
+{
+       int ret;
+
+       if(defapp == NULL)
+               return APPSVC_RET_EINVAL;
+
+       ret = _svc_db_delete_with_pkgname(defapp);
+
+       if(ret < 0) 
+               return APPSVC_RET_ERROR;
+       
+       return APPSVC_RET_OK;
+}
+
+SLPAPI int appsvc_is_defapp(const char *pkg_name)
+{
+       return _svc_db_is_defapp(pkg_name);
+}
+
+SLPAPI int appsvc_data_is_array(bundle *b, const char *key)
+{
+       int type;
+       type = bundle_get_type(b, key);
+
+       if(type <= 0)
+               return 0;
+
+       if(type & BUNDLE_TYPE_ARRAY) 
+               return 1;
+       return 0;
+}
+
+typedef struct _appsvc_transient_cb_info_t{
+       appsvc_host_res_fn cb_func;
+       Ecore_X_Window win_id;
+       void *data;
+}appsvc_transient_cb_info_t;
+
+static Eina_Bool __transient_cb(void *data, int type, void *event)
+{
+       Ecore_X_Event_Window_Hide *ev;
+       appsvc_transient_cb_info_t*  cb_info;
+
+       ev = event;
+       cb_info = (appsvc_transient_cb_info_t*) data;
+
+       if(ev->win == cb_info->win_id) {
+               cb_info->cb_func(cb_info->data);
+               ecore_main_loop_quit();
+       }
+
+       return ECORE_CALLBACK_RENEW;
+}
+
+SLPAPI int appsvc_allow_transient_app(bundle *b, Ecore_X_Window id)
+{
+       char win_id[MAX_LOCAL_BUFSZ];
+
+       snprintf(win_id, MAX_LOCAL_BUFSZ, "%d", id);
+
+       if(b == NULL){
+               _E("bundle for appsvc_allow_transient_app is NULL");
+               return APPSVC_RET_EINVAL;
+       }
+
+       return __set_bundle(b, APP_SVC_K_WIN_ID, win_id);
+}
+
+SLPAPI int appsvc_request_transient_app(bundle *b, Ecore_X_Window callee_id, appsvc_host_res_fn cbfunc, void *data)
+{
+       char *caller = NULL;
+       Ecore_X_Window caller_id;
+
+       caller = bundle_get_val(b, APP_SVC_K_WIN_ID);
+       if(caller == NULL)
+               return APPSVC_RET_ERROR;
+
+       caller_id = atoi(caller);
+
+       ecore_x_icccm_transient_for_set(callee_id, caller_id);
+
+       ecore_x_window_client_manage(caller_id);
+
+       appsvc_transient_cb_info_t* info;
+
+       info = (appsvc_transient_cb_info_t*)calloc(1, sizeof(appsvc_transient_cb_info_t));
+       if(info == NULL)
+               return APPSVC_RET_ERROR;
+
+       info->win_id = caller_id;
+       info->cb_func = cbfunc;
+       info->data = data;
+
+       ecore_event_handler_add(ECORE_X_EVENT_WINDOW_DESTROY, __transient_cb, info);
+
+       return 0;
+}
+
diff --git a/src/appsvc_db.c b/src/appsvc_db.c
new file mode 100755 (executable)
index 0000000..b523441
--- /dev/null
@@ -0,0 +1,387 @@
+/*
+ *  app-svc
+ *
+ * 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 <glib.h>
+
+#include "appsvc_db.h"
+#include "internal.h"
+
+
+#define SVC_DB_PATH    "/opt/dbspace/.appsvc.db"
+#define APP_INFO_DB_PATH       "/opt/dbspace/.app_info.db"
+
+#define QUERY_MAXLEN   4096
+#define BUF_MAX_LEN    1024
+
+#define APPSVC_COLLATION "appsvc_collation"
+
+static sqlite3 *svc_db = NULL;
+static sqlite3 *app_info_db = NULL;
+
+
+
+/**
+ * db initialize
+ */
+static int __init(void)
+{
+       int rc;
+       
+       if (svc_db) {
+               _D("Already initialized\n");
+               return 0;
+       }
+
+       rc = sqlite3_open(SVC_DB_PATH, &svc_db);
+       if(rc) {
+               _E("Can't open database: %s", sqlite3_errmsg(svc_db));
+               goto err;
+       }
+
+       // Enable persist journal mode
+       rc = sqlite3_exec(svc_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(svc_db);
+       return -1;
+}
+
+static int __collate_appsvc(void *ucol, int str1_len, const void *str1, int str2_len, const void *str2)
+{
+       char *saveptr1 = NULL;
+       char *saveptr2 = NULL;
+       char *dup_str1;
+       char *dup_str2;
+       char *token;
+       char *in_op;
+       char *in_uri;
+       char *in_mime;
+       char *op;
+       char *uri;
+       char *mime;
+       int i;
+
+       if(str1 == NULL || str2 == NULL)
+               return -1;
+
+       dup_str1 = strdup(str1);
+       dup_str2 = strdup(str2);
+
+       in_op = strtok_r(dup_str2, "|", &saveptr1);
+       in_uri = strtok_r(NULL, "|", &saveptr1);
+       in_mime = strtok_r(NULL, "|", &saveptr1);
+
+       token = strtok_r(dup_str1, ";", &saveptr1);
+
+       if(token == NULL) {
+               free(dup_str1);
+               free(dup_str2);
+               return -1;
+       }
+
+       do {
+               //_D("token : %s", token);
+               op = strtok_r(token, "|", &saveptr2);
+               uri = strtok_r(NULL, "|", &saveptr2);
+               mime = strtok_r(NULL, "|", &saveptr2);
+
+               if( (strcmp(op, in_op) == 0) && (strcmp(mime, in_mime) == 0) ) {
+                       _D("%s %s %s %s %s %s", op, in_op, mime, in_mime, uri, in_uri);
+                       if(strcmp(uri, in_uri) == 0) {
+                               free(dup_str1);
+                               free(dup_str2);
+                               return 0;
+                       } else {
+                               for(i=0; uri[i]!=0; i++) {
+                                       if(uri[i] == '*') {
+                                               uri[i] = 0;
+                                               if(strstr(in_uri, uri)) {
+                                                       _D("in_uri : %s | uri : %s", in_uri, uri);
+                                                       free(dup_str1);
+                                                       free(dup_str2);
+                                                       return 0;
+                                               }
+                                       }
+                               }
+                       }
+               }
+       } while(token = strtok_r(NULL, ";", &saveptr1));
+
+       free(dup_str1);
+       free(dup_str2);
+
+       return -1;
+}
+
+static int __init_app_info_db(void)
+{
+       int rc;
+
+       if (app_info_db) {
+               _D("Already initialized\n");
+               return 0;
+       }
+
+       rc = sqlite3_open(APP_INFO_DB_PATH, &app_info_db);
+       if(rc) {
+               _E("Can't open database: %s", sqlite3_errmsg(app_info_db));
+               goto err;
+       }
+
+       // Enable persist journal mode
+       rc = sqlite3_exec(app_info_db, "PRAGMA journal_mode = PERSIST", NULL, NULL, NULL);
+       if(SQLITE_OK!=rc){
+               _D("Fail to change journal mode\n");
+               goto err;
+       }
+
+       sqlite3_create_collation(app_info_db, APPSVC_COLLATION, SQLITE_UTF8, NULL,
+                __collate_appsvc);
+
+       return 0;
+err:
+       sqlite3_close(app_info_db);
+       return -1;
+}
+
+
+static int __fini(void)
+{
+       if (svc_db) {
+               sqlite3_close(svc_db);
+               svc_db = NULL;
+       }
+       return 0;
+}
+
+
+int _svc_db_add_app(const char *op, const char *mime_type, const char *uri, const char *pkg_name)
+{
+       char m[BUF_MAX_LEN];
+       char u[BUF_MAX_LEN];
+       char query[BUF_MAX_LEN];
+       char* error_message = NULL;
+
+       if(__init()<0)
+               return -1;
+
+       if(op == NULL )
+               return -1;
+
+       if(mime_type==NULL)
+               strncpy(m,"NULL",BUF_MAX_LEN-1);
+       else 
+               strncpy(m,mime_type,BUF_MAX_LEN-1);
+
+       if(uri==NULL)
+               strncpy(u,"NULL",BUF_MAX_LEN-1);
+       else 
+               strncpy(u,uri,BUF_MAX_LEN-1);
+       
+       sprintf(query,"insert into appsvc( operation, mime_type, uri, pkg_name) \
+               values('%s','%s','%s','%s')",op,m,u,pkg_name);
+
+       if (SQLITE_OK != sqlite3_exec(svc_db, query, NULL, NULL, &error_message))
+       {
+               _E("Don't execute query = %s, error message = %s\n", query, error_message);
+               return -1;
+       }
+       
+       __fini();
+       return 0;
+}
+
+int _svc_db_delete_with_pkgname(const char *pkg_name)
+{
+       char query[BUF_MAX_LEN];
+       char* error_message = NULL;
+       
+       if(pkg_name == NULL) {
+               _E("Invalid argument: data to delete is NULL\n");
+               return -1;
+       }
+
+       if(__init()<0)
+               return -1;
+
+       snprintf(query, BUF_MAX_LEN, "delete from appsvc where pkg_name = '%s';", pkg_name);
+
+       if (SQLITE_OK != sqlite3_exec(svc_db, query, NULL, NULL, &error_message))
+       {
+               _E("Don't execute query = %s, error message = %s\n", query, error_message);
+               return -1;
+       }
+               
+       __fini();
+
+       return 0;
+}
+
+int _svc_db_is_defapp(const char *pkg_name)
+{
+       char query[BUF_MAX_LEN];
+       sqlite3_stmt *stmt;
+       int cnt = 0;
+       int ret = -1;
+       
+       if(pkg_name == NULL) {
+               _E("Invalid argument: data to delete is NULL\n");
+               return 0;
+       }
+
+       if(__init()<0)
+               return 0;
+
+       snprintf(query, BUF_MAX_LEN,
+               "select count(*) from appsvc where pkg_name = '%s';", pkg_name);
+
+       ret = sqlite3_prepare(svc_db, query, sizeof(query), &stmt, NULL);
+       if (ret != SQLITE_OK) {
+               return -1;
+       }
+
+       ret = sqlite3_step(stmt);
+       if (ret == SQLITE_ROW) {
+               cnt = sqlite3_column_int(stmt, 0);
+       }
+       sqlite3_finalize(stmt);
+               
+       __fini();
+
+       if(cnt < 1) return 0;
+
+       return 1;
+}
+
+char* _svc_db_get_app(const char *op, const char *mime_type, const char *uri)
+{
+       char m[BUF_MAX_LEN];
+       char u[BUF_MAX_LEN];
+       char query[BUF_MAX_LEN];
+       sqlite3_stmt* stmt;
+       int ret;
+       char* pkgname;
+
+       if(op == NULL )
+               return NULL;
+
+       if(mime_type==NULL)
+               strncpy(m,"NULL",BUF_MAX_LEN-1);
+       else 
+               strncpy(m,mime_type,BUF_MAX_LEN-1);
+
+       if(uri==NULL)
+               strncpy(u,"NULL",BUF_MAX_LEN-1);
+       else 
+               strncpy(u,uri,BUF_MAX_LEN-1);
+
+//     if(doubt_sql_injection(mime_type))
+//             return NULL;
+       
+       if(__init() < 0)
+               return NULL;
+       
+       
+       sprintf(query,"select pkg_name from appsvc where operation='%s' and mime_type='%s' and uri='%s'",\
+                               op,m,u);
+
+       _D("query : %s\n",query);
+
+       ret = sqlite3_prepare(svc_db, query, strlen(query), &stmt, NULL);
+
+       if ( ret != SQLITE_OK) {
+               _E("prepare error\n");
+               return NULL;
+       }
+
+       ret = sqlite3_step(stmt);
+       if (ret == SQLITE_DONE) {
+               return NULL;
+       }
+
+       pkgname = malloc(BUF_MAX_LEN);
+       strncpy(pkgname, (const char *)sqlite3_column_text(stmt, 0),BUF_MAX_LEN-1);
+       //pkgname = (char*) sqlite3_column_text(stmt, 0);
+
+       _D("pkgname : %s\n",pkgname);
+       
+       ret = sqlite3_finalize(stmt);
+
+       __fini();
+
+       return pkgname;
+}
+
+int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pkg_list)
+{
+       char query[BUF_MAX_LEN];
+       sqlite3_stmt* stmt;
+       int ret;
+       GSList *iter = NULL;
+       char *str = NULL;
+       char *pkgname = NULL;
+       int found;
+
+       if(__init_app_info_db()<0)
+               return 0;
+
+       sprintf(query,"select package from app_info where x_slp_svc='%s|%s|%s' collate appsvc_collation", op,uri,mime);
+       _D("query : %s\n",query);
+
+       ret = sqlite3_prepare(app_info_db, query, strlen(query), &stmt, NULL);
+
+       if ( ret != SQLITE_OK) {
+               _E("prepare error\n");
+               return -1;
+       }
+
+       while (sqlite3_step(stmt) == SQLITE_ROW) {
+               str = sqlite3_column_text(stmt, 0);
+               found = 0;
+               for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+                       pkgname = (char *)iter->data;
+                       if (strncmp(str,pkgname, MAX_PACKAGE_STR_SIZE-1) == 0) {
+                               found = 1;
+                               break;
+                       }
+               }
+               if(found == 0) {
+                       pkgname = strdup(str);
+                       *pkg_list = g_slist_append(*pkg_list, (void *)pkgname);
+                       _D("%s is added",pkgname);
+               }
+       }
+
+       ret = sqlite3_finalize(stmt);
+
+       return 0;
+}
+
+
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..bf61b55
--- /dev/null
@@ -0,0 +1,30 @@
+# Test executables
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS}")
+
+add_executable(appsvc_test
+               appsvc_test.c) 
+target_link_libraries(appsvc_test appsvc ${pkgs_LDFLAGS})
+INSTALL(TARGETS appsvc_test 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/a.out b/test/a.out
new file mode 100755 (executable)
index 0000000..58349ce
Binary files /dev/null and b/test/a.out differ
diff --git a/test/appsvc_test.c b/test/appsvc_test.c
new file mode 100755 (executable)
index 0000000..d900b2b
--- /dev/null
@@ -0,0 +1,334 @@
+/*
+ *  app-svc
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <poll.h>
+#include <stdio.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <Ecore.h>
+#include <aul.h>
+
+#include "appsvc.h"
+
+
+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;
+
+void __set_bundle_from_args(bundle * kb)
+{
+       int opt;
+       char *op = NULL;
+       char *mime = NULL;
+       char *uri = NULL;
+       char *package = NULL;
+       char *category = NULL;
+       char* key = NULL;
+       char* val_array[128];
+       
+       while( (opt = getopt(gargc,gargv,"d:o:m:u:p:c:")) != -1){
+               switch(opt) {
+                       case 'o':
+                               if(optarg)
+                                       op = strdup(optarg);
+                               break;
+                       case 'm':
+                               if(optarg)
+                                       mime = strdup(optarg);
+                               break;
+                       case 'u':
+                               if(optarg)
+                                       uri = strdup(optarg);
+                               break;
+                       case 'p':
+                               if(optarg)
+                                       package = strdup(optarg);
+                               break;
+                       case 'c':
+                               if(optarg)
+                                       category = strdup(optarg);
+                               break;
+                       case 'd':
+                               if(optarg){
+                                       int i = 0;
+                                       key = strtok(optarg,",");
+                                       while(1)
+                                       {
+                                               val_array[i] = strtok(NULL,",");
+                                               if(val_array[i] == NULL)
+                                                       break;
+                                               i++;
+                                       }
+                                       if(i==1) 
+                                               appsvc_add_data(kb, key, val_array[0]);
+                                       else if(i>1) 
+                                               appsvc_add_data_array(kb, key, (const char **)val_array, i);
+                               }
+                               break;
+               }
+       }               
+
+       if(op) {
+               appsvc_set_operation(kb,op);
+               free(op);
+       }
+       if(mime) {
+               appsvc_set_mime(kb,mime);
+               free(mime);
+       }
+       if(uri) {
+               appsvc_set_uri(kb,uri);
+               free(uri);
+       }
+       if(package) {
+               appsvc_set_appid(kb,package);
+               free(package);
+       }
+       if(category) {
+               appsvc_set_category(kb,category);
+               free(category);
+       }
+}
+
+int run_svc()
+{
+       int ret;
+       bundle *kb=NULL;
+       kb = bundle_create();
+       if(kb == NULL)
+       {
+               printf("bundle creation fail\n");
+               return -1;
+       }
+       printf("[run_svc test]\n");
+
+       __set_bundle_from_args(kb);
+       
+       ret = appsvc_run_service(kb,0,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;              
+       }
+}
+
+static void prt_recvd_bundle(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
+{
+       char **array_val;
+       int array_len;
+       size_t *array_item_size;
+
+       char *val;
+       size_t size;
+       int i;
+       
+       if(bundle_keyval_type_is_array((bundle_keyval_t *)kv) > 0) {
+               bundle_keyval_get_array_val((bundle_keyval_t *)kv,
+                       (void ***)&array_val, (unsigned int *)&array_len,
+                       &array_item_size);
+               
+               for (i=0;i<array_len;i++)
+               {
+                       printf("recvd - key: %s[%d], value: %s\n", key, i, array_val[i]);
+               }
+               
+       } else {
+               bundle_keyval_get_basic_val((bundle_keyval_t *)kv, (void **)&val, &size);
+               printf("recvd - key: %s, value: %s\n",key,val);
+       }       
+}
+
+static void cb_func(bundle *kb, int request_code, appsvc_result_val result, void *data)
+{
+       int num;
+       num = (int)data;
+       
+       if(result == APPSVC_RES_CANCEL){
+               printf("==== %d : canceled(preemptted) my request ===\n",num);
+       }
+       else{
+               printf("==== %d : result packet === result %d\n",num, (int)result);
+               //bundle_iterate(kb, prt_recvd_bundle, NULL);
+
+               bundle_foreach(kb, prt_recvd_bundle, NULL);
+       }       
+
+
+       if(strcmp(cmd,"run_svc_res")==0){
+               printf("==== end of appsvc_run() ====\n");
+               ecore_main_loop_quit();
+       }
+}
+
+int run_svc_res()
+{
+       static int num=0;
+       int ret;
+
+       bundle *kb=NULL;
+       kb = bundle_create();
+       if(kb == NULL)
+       {
+               printf("bundle creation fail\n");
+               return -1;
+       }
+       
+       printf("[run_svc_res test]\n");
+       
+       __set_bundle_from_args(kb);     
+       
+       ret = appsvc_run_service(kb, 0, cb_func, (void*)num);
+       
+       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;              
+       }
+}
+
+
+static test_func_t test_func[] = {
+
+
+       {"run_svc", run_svc, "run_svc test",
+               "[usage] run_svc -o <OPERATION> [-m <MIME TYPE>] [-u <URI>] [-d \"<key>,<val>\"]..."},
+       {"run_svc_res", run_svc_res, "run_svc_res test",
+               "[usage] run_svc_res -o <OPERATION> [-m <MIME TYPE>] [-u <URI>] [-d \"<key>,<val>\"]..."},
+               
+};
+
+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;
+}
+
+
+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);
+       }
+
+}
+
+
+static Eina_Bool run_func(void *data)
+{
+       callfunc(cmd);
+
+       if(strcmp(cmd,"run_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;
+}
+
+