tizen 2.4 release accepted/tizen_2.4_mobile tizen_2.4 accepted/tizen/2.4/mobile/20151029.034158 submit/tizen_2.4/20151028.063803 tizen_2.4_mobile_release
authorjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:29:00 +0000 (16:29 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Sat, 24 Oct 2015 07:29:00 +0000 (16:29 +0900)
14 files changed:
CMakeLists.txt
app-svc.manifest
data/appsvc_db.sql [deleted file]
include/SLP_APPSVC_PG.h [deleted file]
include/appsvc.h
include/appsvc_db.h [deleted file]
include/internal.h [deleted file]
include/priv_key.h [deleted file]
packaging/app-svc.spec
res/arm/usr/share/appsvc/alias.ini [deleted file]
src/appsvc.c
src/appsvc_db.c [deleted file]
test/CMakeLists.txt
test/appsvc_test.c

index 4957438..0c1d020 100755 (executable)
@@ -18,13 +18,10 @@ IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
 ENDIF()
 MESSAGE("Build type: ${CMAKE_BUILD_TYPE}")
 
-
 # Set required packages
 INCLUDE(FindPkgConfig)
 
-pkg_check_modules(libpkgs REQUIRED dlog bundle dbus-glib-1 xdgmime aul glib-2.0 ecore-x ecore iniparser pkgmgr-info vconf)
-
-FIND_LIBRARY(LIB_DL dl)
+pkg_check_modules(libpkgs REQUIRED dlog bundle aul ecore-x)
 
 FOREACH(flag ${libpkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
@@ -62,13 +59,10 @@ ENDIF(_APPFW_FEATURE_MULTI_WINDOW)
 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 "-ldl")
 TARGET_LINK_LIBRARIES(appsvc ${libpkgs_LDFLAGS})
 SET_TARGET_PROPERTIES(appsvc PROPERTIES SOVERSION ${VERSION_MAJOR})
 SET_TARGET_PROPERTIES(appsvc PROPERTIES VERSION ${VERSION})
@@ -84,8 +78,6 @@ 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)
 
index 9e9f0de..e8f9198 100644 (file)
@@ -11,7 +11,5 @@
        <assign>
                <filesystem path="/usr/lib/libappsvc.so.0" label="_"/>
                <filesystem path="/usr/lib/libappsvc.so.0.1.0" label="_"/>
-               <filesystem path="/usr/share/appsvc" label="_"/>
-               <filesystem path="/usr/share/appsvc/alias.ini" label="_"/>
        </assign>
 </manifest>
diff --git a/data/appsvc_db.sql b/data/appsvc_db.sql
deleted file mode 100755 (executable)
index 290feee..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-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/include/SLP_APPSVC_PG.h b/include/SLP_APPSVC_PG.h
deleted file mode 100755 (executable)
index 1b491e8..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * app-svc
- *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jyotsna Dhumale <jyotsna.a@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- *
- * @ingroup SLP_PG
- * @defgroup AppSvc_PG App-Svc
- * @{
-
-<h1 class="pg">Introduction</h1>
-AppSvc is a library which provides various features to applications. Its main purpose is to launch suitable application based on combination of MIME type, operation and URI.
-
-<h1 class="pg">AppSvc system context view</h1>
-\image html appsvc_diag.png "Picture 1. AppSvc System Context View"
-\image rtf appsvc_diag.png "Picture 1. AppSvc System context View"
-
-Applications requests app-svc to launch application based on mime type(image/jpeg, image/png, video/3gp, video/3gpp etc), operation (send, view etc) and URI. App-Svc finds the suitable application by referring to default app DB and launches that app. If default app not set, it searches and lists suitable apps by referring to AIL DB using app-selector.
-
-<h1 class="pg">API list and description</h1>
-<ul>
-       <li>appsvc_set_operation() : Sets operation in the bundle </li>
-       <li>appsvc_set_uri() : Sets URI in the bundle</li>
-       <li>appsvc_set_mime() : Sets MIME type in the bundle</li>
-       <li>appsvc_add_data() : Sets an extra data to launch application based on appsvc</li>
-       <li>appsvc_add_data_array() : Sets an extra array data to launch application based on appsvc</li>
-       <li>appsvc_set_pkgname() : Sets package name in the bundle</li>
-       <li>appsvc_set_appid() : Sets app-id in the bundle</li>
-       <li>appsvc_run_service() : Launches application based on parameters set in the bundle</li>
-       <li>appsvc_get_list() : Lists suitable applications matching the bundle parameters</li>
-       <li>appsvc_get_operation() : Gets operation from bundle</li>
-       <li>appsvc_get_uri() : Gets URI from bundle</li>
-       <li>appsvc_get_mime() : Gets MIME from bundle</li>
-       <li>appsvc_get_pkgname() : Gets package name from bundle</li>
-       <li>appsvc_get_appid() : Gets app-id from bundle</li>
-       <li>appsvc_get_data() : Gets data from bundle</li>
-       <li>appsvc_get_data_array() : Gets data array from bundle</li>
-       <li>appsvc_create_result_bundle() : Creates appsvc result bundle based on bundle received in reset event</li>
-       <li>appsvc_send_result() : Sends appsvc result to caller with bundle</li>
-       <li>appsvc_set_defapp() : Sets default app</li>
-       <li>appsvc_unset_defapp() : Unsets default app</li>
-       <li>appsvc_is_defapp() : Checks application is default application or not</li>
-       <li>appsvc_data_is_array() : Checks extra data is array or not</li>
-</ul>
-
- * @}
- */
index 2fcfc16..262ebd9 100755 (executable)
@@ -87,7 +87,7 @@ extern "C" {
 #define APPSVC_OPERATION_FONT_TYPE             "http://tizen.org/appcontrol/operation/configure/font/type"
 /** APP_SVC OPERATION TYPE*/
 #define APPSVC_OPERATION_FONT_SIZE             "http://tizen.org/appcontrol/operation/configure/font/size"
-
+#define APPSVC_OPERATION_LAUNCH_ON_EVENT       "http://tizen.org/appcontrol/operation/launch_on_event"
 
 
 
@@ -126,6 +126,12 @@ extern "C" {
 
 #define APP_SELECTOR "org.tizen.app-selector"
 
+/** Internal operation for launching application which is other zone */
+#define APP_SVC_OPERATION_JUMP "http://tizen.org/appcontrol/operation/jump"
+#define APP_SVC_K_JUMP_ZONE_NAME       "__K_JUMP_DOMAIN_NAME__"
+#define APP_SVC_K_JUMP_ORIGIN_OPERATION        "__K_JUMP_ORIGIN_OPERATION__"
+#define APP_SVC_K_FOCUS_ZONE "__K_FOCUS_ZONE__"
+
 
 /**
  * @brief Return values in appsvc.
@@ -1014,7 +1020,7 @@ int appsvc_is_defapp(const char *appid);
 
  ...
 
- * int is_defapp_browser_app(bundle *b, char *key)
+ * int appsvc_data_is_array(bundle *b, char *key)
  * {
  *      return appsvc_data_is_array(b, key);
  * }
@@ -1028,6 +1034,61 @@ int appsvc_data_is_array(bundle *b, const char *key);
 
 int appsvc_subapp_terminate_request_pid(int pid);
 
+/**
+ * @par Description:
+ * This function sets an uri to launch application based on appsvc.
+ *
+ * @param[in] b bundle object
+ * @param[in] char *mode
+ *
+ * @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>
+
+...
+{
+       appsvc_set_launch_mode(app_control->data, mode);
+}
+ * @endcode
+ *
+ */
+int appsvc_set_launch_mode(bundle *b, const char *mode);
+
+/**
+ * @par Description:
+ * This function sets an uri to launch application based on appsvc.
+ *
+ * @param[in] b bundle object
+ *
+ * @return Pointer for launch mode string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+       appsvc_get_launch_mode(app_control->data);
+}
+ * @endcode
+ *
+ */
+const char *appsvc_get_launch_mode(bundle *b);
 #ifdef __cplusplus
        }
 #endif
diff --git a/include/appsvc_db.h b/include/appsvc_db.h
deleted file mode 100755 (executable)
index c6fb972..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *  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_condition(char *op, char *uri, char *mime, GSList **pkg_list);
-int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pkg_list);
-int _svc_db_get_list_with_all_defapps(GSList **pkg_list);
-int _svc_db_delete_all();
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif         /* __APP_SVC_DB_H__ */
-
diff --git a/include/internal.h b/include/internal.h
deleted file mode 100755 (executable)
index b255ea3..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *  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
deleted file mode 100755 (executable)
index 71ab27d..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- *  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: */
index d6bcacd..480696d 100644 (file)
@@ -14,18 +14,10 @@ Requires(postun): /sbin/ldconfig
 BuildRequires: cmake
 
 BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(ecore) 
-BuildRequires: pkgconfig(ecore-x) 
-BuildRequires: pkgconfig(x11)
-BuildRequires: pkgconfig(libprivilege-control)
 BuildRequires: pkgconfig(bundle)
-BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(xdgmime)
 BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(iniparser)
-BuildRequires: pkgconfig(pkgmgr-info)
-BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(ecore)
+BuildRequires: pkgconfig(ecore-x)
 
 %description
 App svc
@@ -67,35 +59,13 @@ rm -rf %{buildroot}
 mkdir -p %{buildroot}/usr/share/license
 cp LICENSE %{buildroot}/usr/share/license/%{name}
 
-mkdir -p %{buildroot}/usr/share/appsvc
-cp -R %{_builddir}/%{name}-%{version}/res/arm/usr/share/appsvc/* %{buildroot}/usr/share/appsvc
-
-%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
 /opt/usr/devel/appsvc_test
 /usr/lib/libappsvc.so.0
 /usr/lib/libappsvc.so.0.1.0
 /usr/share/license/%{name}
-/usr/share/appsvc/*
-
 
 %files devel
 %defattr(-,root,root,-)
diff --git a/res/arm/usr/share/appsvc/alias.ini b/res/arm/usr/share/appsvc/alias.ini
deleted file mode 100644 (file)
index 63d29a1..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-# Alias
-[Alias]
index 47d8c2f..72e63f2 100755 (executable)
 /*
- *  app-svc
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
  *
- * 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");
+ * 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,
+ * 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 <pthread.h>
-#include <dlfcn.h>
-
 #include <aul.h>
+#include <aul_svc.h>
 #include <Ecore_X.h>
-#include <Ecore.h>
-#include <iniparser.h>
-#include <pkgmgr-info.h>
-#include <vconf.h>
-#include <dlfcn.h>
 
 #include "appsvc.h"
-#include "appsvc_db.h"
-#include "internal.h"
-#include "priv_key.h"
 
 #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;
-       char *win_id;
-       int mime_set;
-}appsvc_resolve_info_t;
-
-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;
-
-pthread_mutex_t iniparser_lock = PTHREAD_MUTEX_INITIALIZER;
-
-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 void __set_transient_for(Ecore_X_Window callee, Ecore_X_Window caller, void *data);
-
-static Eina_Bool __transient_cb(void *data, int type, void *event)
-{
-       Ecore_X_Event_Window_Hide *ev;
-       appsvc_transient_cb_info_t*  cb_info;
-
-       if((!event) || (!data)) {
-               _E("input param of transient cb is null");
-               return ECORE_CALLBACK_CANCEL;
-       }
-
-       ev = event;
-       cb_info = (appsvc_transient_cb_info_t*) data;
-
-       if(ev->win == cb_info->win_id) {
-               if(cb_info->cb_func)
-                       cb_info->cb_func(cb_info->data);
-               ecore_main_loop_quit();
-       }
-
-       return ECORE_CALLBACK_RENEW;
-}
-
-static int __aul_subapp_cb(void *data)
-{
-       appsvc_transient_cb_info_t*  cb_info;
-
-       cb_info = (appsvc_transient_cb_info_t*) data;
-
-       cb_info->cb_func(cb_info->data);
-       ecore_main_loop_quit();
-
-       return 0;
-}
-
-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 ( bundle_get_type(b, APP_SVC_K_SELECTOR_EXTRA_LIST) != BUNDLE_TYPE_NONE ) {
-               if ( !appsvc_get_pkgname(b) ) {
-                       pkgname = APP_SELECTOR;
-               }
-       }
-
-       if (cbfunc) {
-               SECURE_LOGD("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);
-       } else {
-               SECURE_LOGD("pkg_name : %s - no result", pkgname);
-
-#ifdef _APPFW_FEATURE_MULTI_INSTANCE
-               const char* data = bundle_get_val(b, APP_SVC_K_MULTI_INSTANCE);
-               if (data) {
-                       SECURE_LOGD("multi_instance value = %s", data);
-               }
-
-               if (data && strncmp(data, "TRUE", strlen("TRUE")) == 0) {
-                       ret = aul_launch_app_for_multi_instance(pkgname, b);
-               } else {
-                       ret = aul_launch_app(pkgname, b);
-               }
-#else
-               ret = aul_launch_app(pkgname, b);
-#endif
-       }
-
-       if(ret < 0) {
-               switch (ret) {
-                       case AUL_R_EILLACC:
-                               ret = APPSVC_RET_EILLACC;
-                               break;
-                       case AUL_R_EINVAL:
-                               ret = APPSVC_RET_EINVAL;
-                               break;
-                       case AUL_R_ETERMINATING:
-                               ret = APPSVC_RET_ETERMINATING;
-                               break;
-                       case AUL_R_EREJECTED:
-                               ret = APPSVC_RET_EREJECTED;
-                               break;
-                       default:
-                               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;
-       int ret = -1;
-
-       info->op = (char *)appsvc_get_operation(b);
-       info->uri = (char *)appsvc_get_uri(b);
-
-       if((info->uri) && (strcmp(info->uri,"") == 0))
-       {
-               _E("Uri is empty");
-               return APPSVC_RET_EINVAL;
-       }
-
-       info->origin_mime = info->mime = (char *)appsvc_get_mime(b);
-       info->pkgname = (char *)appsvc_get_pkgname(b);
-       info->category = (char *)appsvc_get_category(b);
-       info->win_id = (char *)bundle_get_val(b, APP_SVC_K_WIN_ID);
-
-       if(info->uri) {
-               if(strncmp(info->uri,"/",1) == 0){
-                       if(!info->mime) {
-                               info->origin_mime = info->mime = malloc(MAX_MIME_STR_SIZE);
-                               if (info->origin_mime == NULL) {
-                                       _E("out of memory");
-                                       return APPSVC_RET_ERROR;
-                               }
-
-                               ret = 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->origin_mime = info->mime = malloc(MAX_MIME_STR_SIZE);
-                               if (info->origin_mime == NULL) {
-                                       _E("out of memory");
-                                       return APPSVC_RET_ERROR;
-                               }
-
-                               ret = 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->origin_mime = info->mime = malloc(MAX_MIME_STR_SIZE);
-                               if (info->origin_mime == NULL) {
-                                       _E("out of memory");
-                                       return APPSVC_RET_ERROR;
-                               }
-
-                               ret = aul_get_mime_from_file(&info->uri[7], info->mime, MAX_MIME_STR_SIZE);
-                               info->mime_set = 1;
-                       }
-                       info->uri = NULL;
-               }
-
-               if(info->mime_set == 1 && ret < 0) {
-                       _E("aul_get_mime_from_file : %d", ret);
-                       free(info->mime);
-                       info->origin_mime = info->mime = NULL;
-                       info->mime_set = 0;
-               }
-       }
-
-       if(info->uri) {
-               GRegex *regex;
-               GMatchInfo *match_info;
-               GError *error = NULL;
-
-               regex = g_regex_new ("^(([^:/?#]+):)?(//([^/?#]*))?", 0, 0, &error);
-               if(g_regex_match (regex, info->uri, 0, &match_info) == FALSE) {
-                       g_regex_unref (regex);
-                       return APPSVC_RET_EINVAL;
-               }
-
-               info->scheme = g_match_info_fetch (match_info, 2);
-               info->host = g_match_info_fetch (match_info, 4);
-
-               if(info->scheme && info->host) {
-                       info->uri_r_info = malloc(MAX_SCHEME_STR_SIZE+MAX_HOST_STR_SIZE+2);
-                       if (info->uri_r_info == NULL) {
-                               _E("out of memory");
-                               g_match_info_free(match_info);
-                               g_regex_unref(regex);
-                               return APPSVC_RET_ERROR;
-                       }
-
-                       snprintf(info->uri_r_info, MAX_SCHEME_STR_SIZE+MAX_HOST_STR_SIZE+1,
-                               "%s://%s", info->scheme, info->host);
-               }
-
-               g_match_info_free (match_info);
-               g_regex_unref (regex);
-
-       } else {
-               info->scheme = strdup("NULL");
-       }
-
-       if(!info->mime)
-               info->mime = strdup("NULL");
-       else {
-               info->m_type = malloc(MAX_LOCAL_BUFSZ);
-               if (info->m_type == NULL) {
-                       _E("out of memory");
-                       return APPSVC_RET_ERROR;
-               }
-
-               info->s_type = malloc(MAX_LOCAL_BUFSZ);
-               if (info->s_type == NULL) {
-                       _E("out of memory");
-                       free(info->m_type);
-                       return APPSVC_RET_ERROR;
-               }
-
-               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);
-               }
-
-               info->mime = malloc(MAX_MIME_STR_SIZE);
-               if (info->mime == NULL) {
-                       _E("out of memory");
-                       free(info->s_type);
-                       free(info->m_type);
-                       return APPSVC_RET_ERROR;
-               }
-
-               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);
-       if (info->mime_set)
-               free(info->origin_mime);
-
-       return 0;
-}
-
-static void __set_transient_for(Ecore_X_Window callee, Ecore_X_Window caller, void *data)
-{
-       void (*ecore_x_icccm_transient_for_set) (Ecore_X_Window, Ecore_X_Window);
-       void (*ecore_x_window_client_manage) (Ecore_X_Window);
-       int* ecore_x_event_window_destroy;
-
-       void *handle = dlopen("libecore_x.so.1", RTLD_LAZY | RTLD_LOCAL);
-       if (!handle) {
-               _E("dlopen error %s", dlerror());
-               return;
-       }
-
-       ecore_x_icccm_transient_for_set = dlsym(handle, "ecore_x_icccm_transient_for_set");
-       if (ecore_x_icccm_transient_for_set == NULL)  {
-               _E("dlsym error");
-               dlclose(handle);
-               return;
-       }
-
-       ecore_x_icccm_transient_for_set(callee, caller);
-
-       ecore_x_window_client_manage = dlsym(handle, "ecore_x_window_client_manage");
-       if (ecore_x_window_client_manage == NULL)  {
-               _E("dlsym error");
-               dlclose(handle);
-               return;
-       }
-
-       ecore_x_window_client_manage(caller);
-
-       ecore_x_event_window_destroy = dlsym(handle, "ECORE_X_EVENT_WINDOW_DESTROY");
-       if (ecore_x_event_window_destroy == NULL)  {
-               _E("dlsym error");
-               dlclose(handle);
-               return;
-       }
-
-       ecore_event_handler_add(*ecore_x_event_window_destroy, __transient_cb, data);;
-
-       dlclose(handle);
-}
-
 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);
+       return aul_svc_set_operation(b, 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);
+       return aul_svc_set_uri(b, 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);
+       return aul_svc_set_mime(b, 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);
+       return aul_svc_add_data(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);
+       return aul_svc_add_data_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);
-       pthread_mutex_lock(&iniparser_lock);
-       val = iniparser_getstr(dic, key_string);
-       pthread_mutex_unlock(&iniparser_lock);
-
-       SECURE_LOGD("alias_id : %s", val);
-
-       if(val != NULL) {
-               alias_id = malloc(MAX_PACKAGE_STR_SIZE);
-               if (alias_id == NULL) {
-                       _E("out of memory");
-                       return NULL;
-               }
-
-               strncpy(alias_id, val, MAX_PACKAGE_STR_SIZE-1);
-       }
-
-       iniparser_freedict(dic);
-
-       return alias_id;
+       return aul_svc_set_pkgname(b, pkg_name);
 }
 
 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((char *)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;
+       return aul_svc_set_appid(b, appid);
 }
 
 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);
-       if (tmp == NULL) {
-               _E("out of memory");
-               return -1;
-       }
-
-       _svc_db_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);
-               _svc_db_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, "*/*");
-               _svc_db_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)
-{
-       char *tmp;
-
-       tmp = malloc(MAX_MIME_STR_SIZE);
-       if (tmp == NULL) {
-               _E("out of memory");
-               return -1;
-       }
-
-       _svc_db_get_list_with_collation(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);
-               _svc_db_get_list_with_collation(op, uri, tmp, pkg_list);
-       }
-       if ((strncmp(mime, "NULL", 4) != 0) && (strncmp(m_type, "%", 1) != 0)) {
-               snprintf(tmp, MAX_MIME_STR_SIZE-1, "*/*");
-               _svc_db_get_list_with_collation(op, uri, tmp, pkg_list);
-       }
-       free(tmp);
-
-       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;
-
-       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;
-}
-
-static int __appid_compare(gconstpointer data1, gconstpointer data2)
-{
-       char *a = (char *)data1;
-       char *b = (char *)data2;
-       return strcmp(a,b);
-}
-
-static int __check_mainapp_mode(char *operation)
-{
-#ifdef _APPFW_FEATURE_MULTI_WINDOW
-       int multiwindow_enabled = 0;
-       int     open_via_multi = 0;
-
-       vconf_get_bool(VCONFKEY_QUICKSETTING_MULTIWINDOW_ENABLED, &multiwindow_enabled);
-       vconf_get_bool(VCONFKEY_SETAPPL_OPEN_VIA_MULTI, &open_via_multi);
-
-       if(multiwindow_enabled && open_via_multi
-               && strncmp(operation, "http://tizen.org/appcontrol/operation/view", MAX_OP_STR_SIZE) == 0)
-               return 1;
-#endif
-       return 0;
+       return aul_svc_set_category(b, category);
 }
 
-static int __get_list_with_submode(char *operation, char *win_id, GSList **pkg_list)
+SLPAPI int appsvc_set_launch_mode(bundle *b, const char *mode)
 {
-       GSList *iter = NULL;
-       char *appid = NULL;
-       GSList *find_item = NULL;
-       char *find_appid = NULL;
-       pkgmgrinfo_appinfo_h handle = NULL;
-       char *submode_mainid = NULL;
-       int ret = 0;
-       int mainapp_mode = 0;
-
-       mainapp_mode = __check_mainapp_mode(operation);
-
-       SECURE_LOGD("mainapp_mode : %d", mainapp_mode);
-
-       for (iter = *pkg_list; iter != NULL; ) {
-               find_item = NULL;
-               submode_mainid = NULL;
-               appid = (char *)iter->data;
-               ret = pkgmgrinfo_appinfo_get_appinfo(appid, &handle);
-               if (ret != PMINFO_R_OK){
-                       SECURE_LOGD("pkgmgrinfo_appinfo_get_appinfo with %s failed", appid);
-               }
-               SECURE_LOGD("%s, %x", appid, handle);
-               pkgmgrinfo_appinfo_get_submode_mainid(handle, &submode_mainid);
-               SECURE_LOGD("appid(%s) submode_mainid(%s) win_id(%s)", appid, submode_mainid, win_id);
-               if(submode_mainid) {
-                       if(win_id && !mainapp_mode) {
-                               find_item = g_slist_find_custom(*pkg_list, submode_mainid, __appid_compare);
-                               if(find_item) {
-                                       find_appid = find_item->data;
-                                       if(find_item == g_slist_next(iter)) {
-                                               iter = g_slist_next(find_item);
-                                               *pkg_list = g_slist_remove(*pkg_list, find_appid);
-                                               free(find_appid);
-                                       } else {
-                                               iter = g_slist_next(iter);
-                                               *pkg_list = g_slist_remove(*pkg_list, find_appid);
-                                               free(find_appid);
-                                       }
-                               }
-                       } else {
-                               find_item = g_slist_find_custom(*pkg_list, submode_mainid, __appid_compare);
-                               if(find_item) {
-                                       iter = g_slist_next(iter);
-                                       *pkg_list = g_slist_remove(*pkg_list, appid);
-                                       free(appid);
-                               }
-                       }
-               }
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
-               if(!find_item) {
-                       iter = g_slist_next(iter);
-               }
-       }
-
-       for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
-               appid = (char *)iter->data;
-               SECURE_LOGD("appid(%s)", appid);
-       }
-
-       return 0;
+       return aul_svc_set_launch_mode(b, mode);
 }
 
 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;
-       }
-
-       pkgname = (char *)appsvc_get_pkgname(b);
-
-       /* 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);
-               return ret;
-       }
-
-       memset(&info, 0, sizeof(appsvc_resolve_info_t));
-       ret = __get_resolve_info(b, &info);
-       if(ret < 0)
-               return ret;
-
-       SECURE_LOGD("op - %s / mime - %s / scheme - %s\n", info.op, info.origin_mime, info.scheme);
-
-       /*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);
-
-                       __get_list_with_condition_mime_extened(info.op, "*",
-                               info.mime, info.m_type, info.s_type, &pkg_list);
-
-                       if(info.category) {
-                               __get_list_with_category(info.category, &pkg_list);
-                       }
-
-                       __get_list_with_submode(info.op, info.win_id, &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);
-
-                               __get_list_with_condition_mime_extened(info.op, "*",
-                                                               info.mime, info.m_type, info.s_type, &pkg_list);
-
-                               if(info.category) {
-                                       __get_list_with_category(info.category, &pkg_list);
-                               }
-
-                               __get_list_with_submode(info.op, info.win_id, &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);
-
-               __get_list_with_condition_mime_extened(info.op, "*",
-                                                               info.mime, info.m_type, info.s_type, &pkg_list);
-
-               if(info.category) {
-                       __get_list_with_category(info.category, &pkg_list);
-               }
-
-               __get_list_with_submode(info.op, info.win_id, &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;
+       return aul_svc_run_service(b, request_code, (aul_svc_res_fn)cbfunc, data);
 }
 
 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);
-       }
-
-       __get_list_with_submode(info.op, info.win_id, &pkg_list);
-
-       pkg_count = g_slist_length(pkg_list);
-       if (pkg_count == 0) {
-               _E("Cannot find associated application");
-
-               __free_resolve_info_data(&info);
-               return APPSVC_RET_ENOMATCH;
-       }
-
-       for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
-               pkgname = iter->data;
-               SECURE_LOGD("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;
+       return aul_svc_get_list(b, (aul_svc_info_iter_fn)iter_fn, data);
 }
 
 SLPAPI int appsvc_get_all_defapps(appsvc_info_iter_fn iter_fn, void *data)
 {
-       char *pkgname = NULL;
-       int ret = -1;
-
-       GSList *pkg_list = NULL;
-       GSList *iter = NULL;
-
-       ret = _svc_db_get_list_with_all_defapps(&pkg_list);
-       if(ret < 0)
-               return ret;
-
-       for (iter = pkg_list; iter != NULL; iter = g_slist_next(iter)) {
-               pkgname = iter->data;
-               if( iter_fn(pkgname,data) != 0)
-                       break;
-               g_free(pkgname);
-       }
-
-       g_slist_free(pkg_list);
-
-       return APPSVC_RET_OK;
+       return aul_svc_get_all_defapps((aul_svc_info_iter_fn)iter_fn, data);
 }
 
 SLPAPI const char *appsvc_get_operation(bundle *b)
 {
-       return bundle_get_val(b, APP_SVC_K_OPERATION);
+       return aul_svc_get_operation(b);
 }
 
 SLPAPI const char *appsvc_get_uri(bundle *b)
 {
-       return bundle_get_val(b, APP_SVC_K_URI);
+       return aul_svc_get_uri(b);
 }
 
 SLPAPI const char *appsvc_get_mime(bundle *b)
 {
-       return bundle_get_val(b, APP_SVC_K_MIME);
+       return aul_svc_get_mime(b);
 }
 
 SLPAPI const char *appsvc_get_data(bundle *b, const char *key)
 {
-       return bundle_get_val(b, key);
+       return aul_svc_get_data(b, key);
 }
 
 SLPAPI const char **appsvc_get_data_array(bundle *b, const char *key, int *len)
 {
-       return bundle_get_str_array(b, key, len);
+       return aul_svc_get_data_array(b, key, len);
 }
 
 SLPAPI const char *appsvc_get_pkgname(bundle *b)
 {
-       return bundle_get_val(b, APP_SVC_K_PKG_NAME);
+       return aul_svc_get_pkgname(b);
 }
 
 SLPAPI const char *appsvc_get_appid(bundle *b)
 {
-       return bundle_get_val(b, APP_SVC_K_PKG_NAME);
+       return aul_svc_get_appid(b);
 }
 
 SLPAPI const char *appsvc_get_category(bundle *b)
 {
-       return bundle_get_val(b, APP_SVC_K_CATEGORY);
+       return aul_svc_get_category(b);
 }
 
-SLPAPI int appsvc_create_result_bundle(bundle *inb, bundle **outb)
+SLPAPI const char *appsvc_get_launch_mode(bundle *b)
 {
-       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 aul_svc_get_launch_mode(b);
+}
 
-       return ret;
+SLPAPI int appsvc_create_result_bundle(bundle *inb, bundle **outb)
+{
+       return aul_svc_create_result_bundle(inb, outb);
 }
 
 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;
+       return aul_svc_send_result(b, (aul_svc_result_val)result);
 }
 
 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;
+       return aul_svc_set_defapp(op, mime_type, uri, defapp);
 }
 
 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;
+       return aul_svc_unset_defapp(defapp);
 }
 
 SLPAPI int appsvc_unset_all_defapps()
 {
-       int ret;
-
-       ret = _svc_db_delete_all();
-
-       if(ret < 0)
-               return APPSVC_RET_ERROR;
-
-       return APPSVC_RET_OK;
+       return aul_svc_unset_all_defapps();
 }
 
 SLPAPI int appsvc_is_defapp(const char *pkg_name)
 {
-       return _svc_db_is_defapp(pkg_name);
+       return aul_svc_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;
+       return aul_svc_data_is_array(b, key);
 }
 
 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);
+       return aul_svc_allow_transient_app(b, id);
 }
 
 SLPAPI int appsvc_request_transient_app(bundle *b, Ecore_X_Window callee_id, appsvc_host_res_fn cbfunc, void *data)
 {
-       const char *caller = NULL;
-       Ecore_X_Window caller_id;
-       appsvc_transient_cb_info_t* info;
-
-       caller = bundle_get_val(b, APP_SVC_K_WIN_ID);
-       if(caller == NULL)
-               return APPSVC_RET_ERROR;
-
-       caller_id = atoi(caller);
-
-       if(callee_id == caller_id) {
-               _E("callee window id is same as calleer window id. request will be ignored");
-               return APPSVC_RET_EINVAL;
-       }
-
-       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;
-
-       __set_transient_for(callee_id, caller_id, info);
-
-       aul_set_subapp(__aul_subapp_cb, info);
-
-       return 0;
+       return aul_svc_request_transient_app(b, callee_id, (aul_svc_host_res_fn)cbfunc, data);
 }
 
 SLPAPI int appsvc_subapp_terminate_request_pid(int pid)
 {
-       return aul_subapp_terminate_request_pid(pid);
+       return aul_svc_subapp_terminate_request_pid(pid);
 }
-
diff --git a/src/appsvc_db.c b/src/appsvc_db.c
deleted file mode 100755 (executable)
index 165c34a..0000000
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
- *  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/.pkgmgr_parser.db"
-
-#define QUERY_MAX_LEN  8192
-#define URI_MAX_LEN    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: %d, %s, extended: %d", rc, sqlite3_errmsg(svc_db), sqlite3_extended_errcode(svc_db));
-               goto err;
-       }
-
-       // Enable persist journal mode
-       rc = sqlite3_exec(svc_db, "PRAGMA journal_mode = PERSIST", NULL, NULL, NULL);
-       if(SQLITE_OK!=rc){
-               _E("Fail to change journal mode\n");
-               goto err;
-       }
-
-       return 0;
-err:
-       sqlite3_close(svc_db);
-       svc_db = NULL;
-       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);
-
-       if(!(in_op && in_uri && in_mime)) {
-               _D("op(%s) uri(%s) mime(%s)", in_op, in_uri, in_mime);
-               free(dup_str1);
-               free(dup_str2);
-               return -1;
-       }
-
-       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(!(op && uri && mime)) {
-                       _D("op(%s) uri(%s) mime(%s)", op, uri, mime);
-                       continue;
-               }
-
-               if( (strcmp(op, in_op) == 0) && (strcmp(mime, in_mime) == 0) ) {
-                       SECURE_LOGD("%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)) {
-                                                       SECURE_LOGD("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: %d, %s, extended: %d", rc, sqlite3_errmsg(app_info_db), sqlite3_extended_errcode(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);
-       app_info_db = NULL;
-       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[URI_MAX_LEN];
-       const char insert_query[] = "insert into appsvc( operation, mime_type, uri, pkg_name) values(?,?,?,?)";
-       sqlite3_stmt* p_statement;
-       int result;
-
-       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",URI_MAX_LEN-1);
-       else
-               strncpy(u,uri,URI_MAX_LEN-1);
-
-
-    result = sqlite3_prepare_v2(svc_db, insert_query, strlen(insert_query), &p_statement, NULL);
-    if (result != SQLITE_OK) {
-        _E("Sqlite3 error [%d] : <%s> preparing <%s> querry\n", result, sqlite3_errmsg(svc_db), insert_query);
-               return -1;
-    }
-
-       sqlite3_bind_text(p_statement, 1, op, -1, SQLITE_TRANSIENT);
-       sqlite3_bind_text(p_statement, 2, m, -1, SQLITE_TRANSIENT);
-       sqlite3_bind_text(p_statement, 3, u, -1, SQLITE_TRANSIENT);
-       sqlite3_bind_text(p_statement, 4, pkg_name, -1, SQLITE_TRANSIENT);
-
-
-       result = sqlite3_step(p_statement);
-       if (result != SQLITE_DONE) {
-               _E("Sqlite3 error [%d] : <%s> executing statement\n", result, sqlite3_errmsg(svc_db));
-       }
-
-       result = sqlite3_finalize(p_statement);
-       if (result != SQLITE_OK) {
-               _E("Sqlite3 error [%d] : <%s> finalizing statement\n", result, sqlite3_errmsg(svc_db));
-       }
-
-       __fini();
-       return 0;
-}
-
-int _svc_db_delete_with_pkgname(const char *pkg_name)
-{
-       const char delete_query[] = "delete from appsvc where pkg_name = ?;";
-       sqlite3_stmt* p_statement;
-       int result;
-
-       if(pkg_name == NULL) {
-               _E("Invalid argument: data to delete is NULL\n");
-               return -1;
-       }
-
-       if(__init()<0)
-               return -1;
-
-       result = sqlite3_prepare_v2(svc_db, delete_query, strlen(delete_query), &p_statement, NULL);
-       if (result != SQLITE_OK) {
-               _E("Sqlite3 error [%d] : <%s> preparing <%s> querry\n", result, sqlite3_errmsg(svc_db), delete_query);
-               return -1;
-       }
-
-       sqlite3_bind_text(p_statement, 1, pkg_name, -1, SQLITE_TRANSIENT);
-
-       result = sqlite3_step(p_statement);
-       if (result != SQLITE_DONE) {
-               _E("Sqlite3 error [%d] : <%s> executing statement\n", result, sqlite3_errmsg(svc_db));
-       }
-
-       result = sqlite3_finalize(p_statement);
-       if (result != SQLITE_OK) {
-               _E("Sqlite3 error [%d] : <%s> finalizing statement\n", result, sqlite3_errmsg(svc_db));
-       }
-
-       __fini();
-
-       return 0;
-}
-
-int _svc_db_delete_all()
-{
-       char query[QUERY_MAX_LEN];
-       char* error_message = NULL;
-
-       if(__init()<0)
-               return -1;
-
-       snprintf(query, QUERY_MAX_LEN, "delete from appsvc;");
-
-       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[QUERY_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, QUERY_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) {
-               _E("prepare error, ret = %d, extended = %d\n", ret, sqlite3_extended_errcode(svc_db));
-               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[URI_MAX_LEN];
-       char query[QUERY_MAX_LEN];
-       sqlite3_stmt* stmt;
-       int ret;
-       char* pkgname;
-       char* ret_val = NULL;
-
-       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",URI_MAX_LEN-1);
-       else
-               strncpy(u,uri,URI_MAX_LEN-1);
-
-//     if(doubt_sql_injection(mime_type))
-//             return NULL;
-
-       if(__init() < 0)
-               return NULL;
-
-
-       snprintf(query, QUERY_MAX_LEN, "select pkg_name from appsvc where operation='%s' and mime_type='%s' and uri='%s'",\
-                               op,m,u);
-
-       SECURE_LOGD("query : %s\n",query);
-
-       ret = sqlite3_prepare(svc_db, query, strlen(query), &stmt, NULL);
-       if ( ret != SQLITE_OK) {
-               _E("prepare error, ret = %d, extended = %d\n", ret, sqlite3_extended_errcode(svc_db));
-               goto db_fini;
-       }
-
-       ret = sqlite3_step(stmt);
-       if (ret != SQLITE_ROW) {
-               _D("no result");
-               goto stmt_finialize;
-       }
-
-       pkgname = (char*) sqlite3_column_text(stmt, 0);
-       if(pkgname) {
-               ret_val = malloc(BUF_MAX_LEN);
-               if (ret_val == NULL) {
-                       _E("out of memory");
-                       goto stmt_finialize;
-               }
-
-               strncpy(ret_val, (const char *)sqlite3_column_text(stmt, 0),BUF_MAX_LEN-1);
-       }
-
-       SECURE_LOGD("pkgname : %s\n",pkgname);
-
-stmt_finialize :
-       ret = sqlite3_finalize(stmt);
-       if ( ret != SQLITE_OK) {
-               _D("finalize error(%d)", ret);
-       }
-
-db_fini :
-       __fini();
-
-       return ret_val;
-}
-
-int _svc_db_get_list_with_condition(char *op, char *uri, char *mime, GSList **pkg_list)
-{
-       char query[QUERY_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;
-
-       snprintf(query, QUERY_MAX_LEN, "select ac.app_id from package_app_app_control as ac, package_app_info ai where ac.app_id = ai.app_id and ac.app_control like '%%%s|%s|%s%%' and ai.app_disable='false'", op,uri,mime);
-       SECURE_LOGD("query : %s\n",query);
-
-       ret = sqlite3_prepare(app_info_db, query, strlen(query), &stmt, NULL);
-       if ( ret != SQLITE_OK) {
-               _E("prepare error, ret = %d, extended = %d\n", ret, sqlite3_extended_errcode(app_info_db));
-               return -1;
-       }
-
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               str = (char *)sqlite3_column_text(stmt, 0);
-               if (str == NULL) {
-                       continue;
-               }
-
-               found = 0;
-               for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
-                       pkgname = (char *)iter->data;
-                       if (pkgname && 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;
-}
-
-int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pkg_list)
-{
-       char query[QUERY_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;
-
-       snprintf(query, QUERY_MAX_LEN, "select ac.app_id from package_app_app_control as ac, package_app_info ai where ac.app_id = ai.app_id and ac.app_control='%s|%s|%s' collate appsvc_collation and ai.app_disable='false'", op,uri,mime);
-       SECURE_LOGD("query : %s\n",query);
-
-       ret = sqlite3_prepare(app_info_db, query, strlen(query), &stmt, NULL);
-       if ( ret != SQLITE_OK) {
-               _E("prepare error, ret = %d, extended = %d\n", ret, sqlite3_extended_errcode(app_info_db));
-               return -1;
-       }
-
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               str = (char *)sqlite3_column_text(stmt, 0);
-               if (str == NULL) {
-                       continue;
-               }
-
-               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;
-}
-
-int _svc_db_get_list_with_all_defapps(GSList **pkg_list)
-{
-       char query[QUERY_MAX_LEN];
-       sqlite3_stmt* stmt;
-       int ret;
-       GSList *iter = NULL;
-       char *str = NULL;
-       char *pkgname = NULL;
-       int found;
-
-       if(__init()<0)
-               return 0;
-
-       snprintf(query, QUERY_MAX_LEN, "select pkg_name from appsvc");
-
-       ret = sqlite3_prepare(svc_db, query, sizeof(query), &stmt, NULL);
-       if ( ret != SQLITE_OK) {
-               _E("prepare error, ret = %d, extended = %d\n", ret, sqlite3_extended_errcode(svc_db));
-               return -1;
-       }
-
-       while (sqlite3_step(stmt) == SQLITE_ROW) {
-               str = (char *)sqlite3_column_text(stmt, 0);
-               if (str == NULL) {
-                       continue;
-               }
-
-               found = 0;
-               for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
-                       pkgname = (char *)iter->data;
-                       if (pkgname && 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 def app",pkgname);
-               }
-       }
-
-       ret = sqlite3_finalize(stmt);
-
-       return 0;
-}
-
index a8589c1..0194516 100755 (executable)
@@ -1,6 +1,6 @@
 # Test executables
 
-pkg_check_modules(pkgs REQUIRED dlog ecore x11 libprivilege-control aul)
+pkg_check_modules(pkgs REQUIRED dlog ecore aul)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(TEST_CFLAGS "${TEST_CFLAGS} ${flag}")
@@ -9,7 +9,7 @@ ENDFOREACH(flag)
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_CFLAGS} -fPIE")
 
 add_executable(appsvc_test
-               appsvc_test.c) 
+               appsvc_test.c)
 target_link_libraries(appsvc_test appsvc ${pkgs_LDFLAGS} "-pie")
 INSTALL(TARGETS appsvc_test DESTINATION /opt/usr/devel)
 
index 835581a..ec9e82e 100755 (executable)
@@ -45,35 +45,30 @@ typedef struct _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)
-                                       op = strdup(optarg);
+                               if(optarg)
+                                       appsvc_set_operation(kb, optarg);
                                break;
                        case 'm':
-                               if(optarg && !mime)
-                                       mime = strdup(optarg);
+                               if(optarg)
+                                       appsvc_set_mime(kb,optarg);
                                break;
                        case 'u':
-                               if(optarg && !uri)
-                                       uri = strdup(optarg);
+                               if(optarg)
+                                       appsvc_set_uri(kb,optarg);
                                break;
                        case 'p':
-                               if(optarg && !package)
-                                       package = strdup(optarg);
+                               if(optarg)
+                                       appsvc_set_appid(kb,optarg);
                                break;
                        case 'c':
-                               if(optarg && !category)
-                                       category = strdup(optarg);
+                               if(optarg)
+                                       appsvc_set_category(kb,optarg);
                                break;
                        case 'd':
                                if(optarg){
@@ -94,27 +89,6 @@ void __set_bundle_from_args(bundle * kb)
                                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()