#include <bundle.h>
-#include <sys/types.h>
#ifdef __cplusplus
extern "C" {
/** APP_SVC OPERATION TYPE*/
#define APPSVC_OPERATION_MULTI_SHARE "http://tizen.org/appcontrol/operation/multi_share"
/** APP_SVC OPERATION TYPE*/
-#define APPSVC_OPERATION_COMPOSE "http://tizen.org/appcontrol/opeation/compose"
+#define APPSVC_OPERATION_COMPOSE "http://tizen.org/appcontrol/operation/compose"
/** APP_SVC OPERATION TYPE*/
#define APPSVC_OPERATION_LOCATION "http://tizen.org/appcontrol/operation/configure/location"
/** APP_SVC OPERATION TYPE*/
#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"
-/** APP_SVC OPERATION TYPE*/
-#define APPSVC_OPERATION_LAUNCH_ON_EVENT "http://tizen.org/appcontrol/operation/launch_on_event"
-
+#define APPSVC_OPERATION_LAUNCH_ON_EVENT "http://tizen.org/appcontrol/operation/launch_on_event"
/** APP SVC internal private key */
#define APP_SVC_K_URI_R_INFO "__APP_SVC_URI_R_INFO__"
+#define APP_SVC_K_SELECTOR_EXTRA_LIST "http://tizen.org/appcontrol/data/selector_extra_list"
+
+#ifdef _APPFW_FEATURE_MULTI_INSTANCE
+#define APP_SVC_K_MULTI_INSTANCE "multi_instance"
+#endif
+
#define APP_SELECTOR "org.tizen.app-selector"
-#define APPSVC_K_LAUNCH_RESULT_APP_STARTED "__K_LAUNCH_RESULT_APP_STARTED__"
+/** 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.
+ * @brief Return values in appsvc.
*/
typedef enum _appsvc_return_val {
+ APPSVC_RET_EREJECTED = -7, /**< application launch rejected */
+ APPSVC_RET_ETERMINATING = -6, /**< application terminating */
APPSVC_RET_EILLACC = -5, /**< Illegal Access */
APPSVC_RET_ELAUNCH = -4, /**< Failure on launching the app */
APPSVC_RET_ENOMATCH = -3, /**< No matching result Error */
/**
- * @brief result values in appsvc.
+ * @brief result values in appsvc.
*/
typedef enum _appsvc_result_val {
APPSVC_RES_CANCEL = -2, /**< Cancel by system */
}appsvc_result_val;
-/**
+/**
* @brief appsvc_res_fn is appsvc result function
- * @param[out] b result bundle
+ * @param[out] b result bundle
* @param[out] request_code request code
* @param[out] result result value
- * @param[out] data user-supplied data
+ * @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
+/**
+ * @brief iterator function running with appsvc_get_list
+ * @param[out] appid appid retreived by appsvc_get_list
+ * @param[out] data user-supplied data
*/
typedef int (*appsvc_info_iter_fn)(const char *appid, void *data);
* @par Description:
* This function sets an operation to launch application based on appsvc.
*
- * @param[in] b bundle object
- * @param[in] operation operation
+ * @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_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.
+ * @remarks An application must call this function before using appsvc_run_service API.
*
* @par Sample code:
* @code
bundle *b = NULL;
b = bundle_create();
-
+
appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
}
* @endcode
* @par Description:
* This function sets an uri to launch application based on appsvc.
*
- * @param[in] b bundle object
- * @param[in] uri uri
+ * @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_ERROR - general error
* @retval APPSVC_RET_EINVAL - invalid argument(content)
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
bundle *b = NULL;
b = bundle_create();
-
+
appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
appsvc_set_uri(b,"http://www.samsung.com");
}
* @par Description:
* This function sets a mime-type to launch application based on appsvc.
*
- * @param[in] b bundle object
- * @param[in] mime mime-type
+ * @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_ERROR - general error
* @retval APPSVC_RET_EINVAL - invalid argument(content)
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
bundle *b = NULL;
b = bundle_create();
-
+
appsvc_set_operation(b, APPSVC_OPERATION_PICK);
appsvc_set_mime(b,"image/jpg");
}
* @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
+ * @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.
+ * @remarks None.
*
* @par Sample code:
* @code
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");
* @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] 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.
+ * @remarks None.
*
* @par Sample code:
* @code
* @par Description:
* This function sets a package name to launch application based on appsvc.
*
- * @param[in] b bundle object
+ * @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_ERROR - general error
* @retval APPSVC_RET_EINVAL - invalid argument(content)
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
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");
*
* @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_ERROR - general error
* @retval APPSVC_RET_EINVAL - invalid argument(content)
- * @retval APPSVC_RET_ENOMATCH - no matching result Error
+ * @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.
+ * @remarks None.
*
* @par Sample code:
* @code
static int num = 0;
b = bundle_create();
-
+
appsvc_set_operation(b, APPSVC_OPERATION_PICK);
appsvc_set_mime(b,"image/jpg");
* @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
+ * @retval APPSVC_RET_ENOMATCH - no matching result Error
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
#include <appsvc.h>
-static int iter_fn(const char* pkg_name, void *data)
+static int iter_fn(const char* appid, void *data)
{
printf("\t==========================\n");
- printf("\t pkg_name: %s\n", pkg_name);
+ printf("\t appid: %s\n", appid);
printf("\t==========================\n");
return 0;
}
static int num = 0;
b = bundle_create();
-
+
appsvc_set_operation(b, APPSVC_OPERATION_PICK);
appsvc_set_mime(b,"image/jpg");
/**
* @par Description:
+ * This API use to get default applications
+ *
+ * @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* appid, void *data)
+{
+ printf("\t==========================\n");
+ printf("\t appid : %s\n", appid);
+ printf("\t==========================\n");
+ return 0;
+}
+
+...
+{
+ return appsvc_get_all_defapps(iter_fn, (void*)NULL);
+}
+ * @endcode
+ *
+ */
+int appsvc_get_all_defapps(appsvc_info_iter_fn iter_fn, void *data);
+
+/**
+ * @par Description:
* This function gets a operation from bundle.
*
- * @param[in] b bundle object
+ * @param[in] b bundle object
*
* @return Pointer for operation string if success, NULL if fail
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
...
{
- char *val;
+ char *val;
val = appsvc_get_operation(b);
}
* @endcode
* @par Description:
* This function gets a uri from bundle.
*
- * @param[in] b bundle object
+ * @param[in] b bundle object
*
* @return Pointer for uri string if success, NULL if fail
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
...
{
- char *val;
+ char *val;
val = appsvc_get_uri(b);
}
* @endcode
* @par Description:
* This function gets a mime-type from bundle.
*
- * @param[in] b bundle object
+ * @param[in] b bundle object
*
* @return Pointer for mime-type string if success, NULL if fail
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
...
{
- char *val;
+ char *val;
val = appsvc_get_mime(b);
}
* @endcode
* @par Description:
* This function gets a package name from bundle.
*
- * @param[in] b bundle object
+ * @param[in] b bundle object
*
* @return Pointer for package name string if success, NULL if fail
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
...
{
- char *val;
+ char *val;
val = appsvc_get_pkgname(b);
}
* @endcode
* @par Description:
* This function gets value from key.
*
- * @param[in] b bundle object
+ * @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.
+ * @remarks None.
*
* @par Sample code:
* @code
...
{
- char *val;
+ char *val;
val = appsvc_get_data(b, APPSVC_DATA_CC);
}
* @endcode
* @par Description:
* This function gets value from key.
*
- * @param[in] b bundle object
+ * @param[in] b bundle object
* @param[in] key key
* @param[out] len length of array
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
...
{
- char **val_array;
+ 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
+ else
val = appsvc_get_data(b, APPSVC_DATA_SELECTED);
}
* @endcode
* @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
+ * @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_ERROR - general error
* @retval APPSVC_RET_EINVAL - invalid argument(content)
*
* @pre None.
* @post None.
* @see appsvc_send_result.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
{
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);
* @param[in] result result value
*
* @retval APPSVC_RET_OK - success
- * @retval APPSVC_RET_ERROR - general error
+ * @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.
+ * @remarks None.
*
* @par Sample code:
* @code
{
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);
* @param[in] defapp default application
*
* @retval APPSVC_RET_OK - success
- * @retval APPSVC_RET_ERROR - general error
+ * @retval APPSVC_RET_ERROR - general error
* @retval APPSVC_RET_EINVAL - invalid argument(content)
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
* @param[in] defapp default application
*
* @retval APPSVC_RET_OK - success
- * @retval APPSVC_RET_ERROR - general error
+ * @retval APPSVC_RET_ERROR - general error
*
* @pre None.
* @post None.
* @see None.
- * @remarks None.
+ * @remarks None.
*
* @par Sample code:
* @code
/**
* @par Description:
+ * This API unset all of default applications associated with op, uri and mime-type.
+ *
+ *
+ * @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_all_defapps();
+}
+ * @endcode
+ *
+ */
+int appsvc_unset_all_defapps();
+
+/**
+ * @par Description:
* This API ask a application is default application or not.
*
- * @param[in] pkg_name application package name
+ * @param[in] appid application appid
* @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.
+ * @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, uid_t uid);
+
/**
* @par Description:
* This API ask a extra data is array or not.
*
- * @param[in] b bundle object
- * @param[in] key key of extra data
+ * @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.
+ * @remarks None.
*
* @par Sample code:
* @code
#include <appsvc.h>
-
+
...
* int appsvc_data_is_array(bundle *b, char *key)
* @endcode
* @remark
* None
-*
+*
*/
int appsvc_data_is_array(bundle *b, const char *key);
*
*/
const char *appsvc_get_launch_mode(bundle *b);
-
-int aul_svc_subscribe_launch_result(bundle *b, const char *event);
#ifdef __cplusplus
}
#endif
/*
- * 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 <unistd.h>
-#include <sys/types.h>
-
#include <aul.h>
-#include <libsoup/soup.h>
+#include <aul_svc.h>
+#include <Ecore.h>
#ifndef WAYLAND
#include <Ecore_X.h>
#endif
-#include <Ecore.h>
-#include <iniparser.h>
-#include <pkgmgr-info.h>
-#include <tzplatform_config.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;
-
-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 int __get_list_with_condition(char *op, char *uri,
- char *mime, GSList **pkg_list, uid_t uid);
-
-
-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);
- } else {
- _D("pkg_name : %s - no result", pkgname);
- ret = aul_launch_app(pkgname, b);
- }
-
- 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_ENOAPP:
- ret = APPSVC_RET_ENOMATCH;
- 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;
- 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);
- 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);
- 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);
- 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);
- 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);
- }
-
- 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);
- if (info->mime_set)
- free(info->origin_mime);
-
- return 0;
-}
-
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);
- val = iniparser_getstring(dic, key_string, NULL);
-
- _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;
+ 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(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);
+ return aul_svc_set_category(b, category);
}
SLPAPI int appsvc_set_launch_mode(bundle *b, const char *mode)
{
- if (b == NULL) {
- _E("bundle for appsvc_set_launch_mode is NULL");
- return APPSVC_RET_EINVAL;
- }
-
- return __set_bundle(b, APP_SVC_K_LAUNCH_MODE, mode);
-}
-static int __get_list_with_condition_mime_extened(char *op, char *uri, char *mime,
- char *m_type, char *s_type, GSList **pkg_list, uid_t uid)
-{
- char *tmp;
-
- tmp = malloc(MAX_MIME_STR_SIZE);
-
- _svc_db_get_list_with_condition(op, uri, mime, pkg_list, uid);
- 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, uid);
- }
- 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, uid);
- }
- 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, uid_t uid)
-{
- char *tmp;
-
- tmp = malloc(MAX_MIME_STR_SIZE);
-
- _svc_db_get_list_with_collation(op, uri, mime, pkg_list, uid);
- 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, uid);
- }
- 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, uid);
- }
- 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, uid_t uid)
-{
- 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_usr_filter_foreach_appinfo(handle, __app_list_cb, &app_list, uid);
- 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 __get_list_with_submode(char *win_id, GSList **pkg_list, uid_t uid)
-{
- int ret;
- GSList *iter = NULL;
- char *appid = NULL;
- GSList *find_item = NULL;
- char *find_appid = NULL;
- pkgmgrinfo_appinfo_h handle = NULL;
- char *submode_mainid = NULL;
-
-#ifndef WAYLAND
- for (iter = *pkg_list; iter != NULL; ) {
- find_item = NULL;
- submode_mainid = NULL;
- appid = (char *)iter->data;
- ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, uid, &handle);
- SECURE_LOGD("ret %d, %s, %x", ret, appid, handle);
- ret = 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) {
- 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);
- }
- }
-#endif
-
- 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)
{
- //using default user to allow app-svc API usage for deamon.
- //App-svc run service leads to app launch that could require a graphical session.
- //Indeed bluetooth_agent uses this API and is launched as bluetooth user (that not regular user).
- return appsvc_usr_run_service(b, request_code, cbfunc, data, tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+ return aul_svc_run_service(b, request_code, (aul_svc_res_fn)cbfunc, data);
}
SLPAPI int appsvc_usr_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, void *data, uid_t uid)
{
- 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;
-
- _D("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, uid);
- 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, uid);
- 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, uid);
- }
-
- __get_list_with_condition_mime_extened(info.op, info.scheme,
- info.mime, info.m_type, info.s_type, &pkg_list, uid);
-
- __get_list_with_condition_mime_extened(info.op, "*",
- info.mime, info.m_type, info.s_type, &pkg_list, uid);
-
- if(info.category) {
- __get_list_with_category(info.category, &pkg_list, uid);
- }
-
- __get_list_with_submode(info.win_id, &pkg_list, uid);
-
- 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, uid);
-
- 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, uid);
- 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, uid);
-
- __get_list_with_condition_mime_extened(info.op, "*",
- info.mime, info.m_type, info.s_type, &pkg_list, uid);
-
- if(info.category) {
- __get_list_with_category(info.category, &pkg_list, uid);
- }
-
- __get_list_with_submode(info.win_id, &pkg_list, uid);
-
- 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, uid);
-
- if(pkgname==NULL){
- __get_list_with_condition_mime_extened(info.op, info.scheme,
- info.mime, info.m_type, info.s_type, &pkg_list, uid);
-
- __get_list_with_condition_mime_extened(info.op, "*",
- info.mime, info.m_type, info.s_type, &pkg_list, uid);
-
- if(info.category) {
- __get_list_with_category(info.category, &pkg_list, uid);
- }
-
- __get_list_with_submode(info.win_id, &pkg_list, uid);
-
- 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_with_uid(b, request_code, (aul_svc_res_fn)cbfunc, data, uid);
}
-
SLPAPI int appsvc_get_list(bundle *b, appsvc_info_iter_fn iter_fn, void *data)
{
- //using default user to allow app-svc API usage for deamon.
- //App-svc run get list leads to app launch that could require a graphical session.
- return appsvc_usr_get_list(b, iter_fn, data, tzplatform_getuid(TZ_SYS_DEFAULT_USER));
+ return aul_svc_get_list(b, (aul_svc_info_iter_fn)iter_fn, data);
}
SLPAPI int appsvc_usr_get_list(bundle *b, appsvc_info_iter_fn iter_fn, void *data, uid_t uid)
{
- 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 / scheme - %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, uid);
-
- 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, uid);
- }
-
- __get_list_with_condition_mime_extened(info.op, info.scheme,
- info.mime, info.m_type, info.s_type, &pkg_list, uid);
-
- if(info.category) {
- __get_list_with_category(info.category, &pkg_list, uid);
- }
-
- __get_list_with_submode(info.win_id, &pkg_list, uid);
-
- 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 aul_svc_get_list_with_uid(b, (aul_svc_info_iter_fn)iter_fn, data, uid);
+}
- return APPSVC_RET_OK;
+SLPAPI int appsvc_get_all_defapps(appsvc_info_iter_fn iter_fn, void *data)
+{
+ 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 const char *appsvc_get_launch_mode(bundle *b)
{
- return bundle_get_val(b, APP_SVC_K_LAUNCH_MODE);
+ return aul_svc_get_launch_mode(b);
}
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;
+ 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, uid_t uid)
{
- int ret;
-
- if(op == NULL || defapp == NULL)
- return APPSVC_RET_EINVAL;
-
- ret = _svc_db_add_app(op, mime_type, uri, defapp, uid);
-
- if(ret < 0)
- return APPSVC_RET_ERROR;
-
- return APPSVC_RET_OK;
+ return aul_svc_set_defapp_with_uid(op, mime_type, uri, defapp, uid);
}
SLPAPI int appsvc_unset_defapp(const char *defapp, uid_t uid)
{
- int ret;
-
- if(defapp == NULL)
- return APPSVC_RET_EINVAL;
-
- ret = _svc_db_delete_with_pkgname(defapp, uid);
-
- if(ret < 0)
- return APPSVC_RET_ERROR;
-
- return APPSVC_RET_OK;
+ return aul_svc_unset_defapp_with_uid(defapp, uid);
}
-SLPAPI int appsvc_is_defapp(const char *pkg_name, uid_t uid)
+SLPAPI int appsvc_unset_all_defapps()
{
- return _svc_db_is_defapp(pkg_name, uid);
-}
-
-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_unset_all_defapps();
}
-typedef struct _appsvc_transient_cb_info_t{
- appsvc_host_res_fn cb_func;
-
-#ifndef WAYLAND
- Ecore_X_Window win_id;
-#endif
-
- void *data;
-}appsvc_transient_cb_info_t;
-
-static Eina_Bool __transient_cb(void *data, int type, void *event)
+SLPAPI int appsvc_is_defapp(const char *pkg_name, uid_t uid)
{
-#ifndef WAYLAND
- 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();
- }
-#endif
- return ECORE_CALLBACK_RENEW;
+ return aul_svc_is_defapp_with_uid(pkg_name, uid);
}
-int __aul_subapp_cb(void *data)
+SLPAPI int appsvc_data_is_array(bundle *b, const char *key)
{
- 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;
+ return aul_svc_data_is_array(b, key);
}
#ifndef WAYLAND
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);
}
#else
SLPAPI int appsvc_allow_transient_app(bundle *b, unsigned int id)
{
- return 0;
+ return aul_svc_allow_transient_app(b, id);
}
#endif
#ifndef WAYLAND
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);
- 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);
}
#else
SLPAPI int appsvc_request_transient_app(bundle *b, unsigned int callee_id, appsvc_host_res_fn cbfunc, void *data)
{
- return 0;
+ return aul_svc_request_transient_app(b, callee_id, (aul_svc_host_res_fn)cbfunc, data);
}
#endif
SLPAPI int appsvc_subapp_terminate_request_pid(int pid)
{
- int cpid = getpid();
- int lcnt;
- int *lpids = NULL;
- int i;
-
- aul_app_group_get_leader_pids(&lcnt, &lpids);
- for (i = 0; i < lcnt; i++) {
- if (lpids[i] == cpid) {
- int cnt;
- int *pids = NULL;
-
- aul_app_group_get_group_pids(cpid, &cnt, &pids);
-
- if (cnt == 0) {
- free(lpids);
- return aul_subapp_terminate_request_pid(pid);
- }
-
- if (pids != NULL)
- free(pids);
- break;
- }
- }
-
- if (lpids != NULL)
- free(lpids);
-
- return aul_app_group_clear_top();
-}
-
-SLPAPI int aul_svc_subscribe_launch_result(bundle *b, const char *result)
-{
- if (b == NULL) {
- _E("bundle for aul_svc_subscribe_launch_result is NULL");
- return APPSVC_RET_EINVAL;
- }
-
- return __set_bundle(b, result, "1");
+ return aul_svc_subapp_terminate_request_pid(pid);
}
+++ /dev/null
-/*
- * 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 <sys/stat.h>
-#include <errno.h>
-#include <glib.h>
-#include <tzplatform_config.h>
-
-#include "appsvc_db.h"
-#include "internal.h"
-
-#define SVC_DB_PATH tzplatform_mkpath(TZ_SYS_DB, ".appsvc.db")
-#define APP_INFO_DB_PATH tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
-
-#define QUERY_MAX_LEN 8192
-#define URI_MAX_LEN 4096
-#define BUF_MAX_LEN 1024
-#define BUFSIZE 4096
-#define ROOT_UID 0
-
-#define APPSVC_COLLATION "appsvc_collation"
-
-#define QUERY_CREATE_TABLE_APPSVC "create table if not exists appsvc " \
- "(operation text, " \
- "mime_type text, " \
- "uri text, " \
- "pkg_name text, " \
- "PRIMARY KEY(pkg_name)) "
-
-static sqlite3 *svc_db = NULL;
-static sqlite3 *app_info_db = NULL;
-
-static int _mkdir(const char *dir, mode_t mode)
-{
- char tmp[PATH_MAX];
- char *p = NULL;
- size_t len;
- int ret;
-
- snprintf(tmp, sizeof(tmp), "%s", dir);
- len = strlen(tmp);
- if(tmp[len - 1] == '/')
- tmp[len - 1] = 0;
- for(p = tmp + 1; *p; p++) {
- if(*p == '/') {
- *p = 0;
- ret = mkdir(tmp, mode);
- if (ret && errno != EEXIST)
- return ret;
- *p = '/';
- }
- }
- return mkdir(tmp, mode);
-}
-
-static void _mkdir_for_user(const char* dir, uid_t uid, gid_t gid) {
- int ret = 0;
-
- ret = _mkdir(dir, S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH);
- if (ret == -1 && errno != EEXIST) {
- _E("FAIL : to create directory %s %d", dir, errno);
- } else if (getuid() == ROOT_UID) {
- ret = chown(dir, uid, gid);
- if (ret == -1)
- _E("FAIL : chown %s %d.%d, because %s", dir, uid, gid, strerror(errno));
- }
-}
-
-static char* getUserSvcDB(uid_t uid)
-{
- const char *appsvc_db = NULL;
- const char *db_path = NULL;
- uid_t uid_caller = getuid();
- gid_t gid = ROOT_UID;
-
- if (uid == ROOT_UID) {
- _E("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
-
- if (uid != tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) {
- tzplatform_set_user(uid);
- appsvc_db = tzplatform_mkpath(TZ_USER_DB, ".appsvc.db");
- db_path = tzplatform_getenv(TZ_USER_DB);
- gid = tzplatform_getgid(TZ_USER_NAME);
- tzplatform_reset_user();
- } else {
- appsvc_db = tzplatform_mkpath(TZ_SYS_DB, ".appsvc.db");
- db_path = tzplatform_getenv(TZ_SYS_DB);
- }
-
- // just allow certain users to create missing directory.
- if (uid_caller == ROOT_UID || uid_caller == uid)
- _mkdir_for_user (db_path, uid, gid);
-
- return appsvc_db;
-}
-
-
-static char* getUserAppDB(uid_t uid)
-{
- const char *app_info_db = NULL;
- const char *db_path = NULL;
- uid_t uid_caller = getuid();
- gid_t gid = ROOT_UID;
-
- if (uid == ROOT_UID) {
- _E("FAIL : Root is not allowed user! please fix it replacing with DEFAULT_USER");
- return NULL;
- }
-
- if (uid != tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)) {
- tzplatform_set_user(uid);
- app_info_db = tzplatform_mkpath(TZ_USER_DB, ".pkgmgr_parser.db");
- db_path = tzplatform_getenv(TZ_USER_DB);
- gid = tzplatform_getgid(TZ_USER_NAME);
- tzplatform_reset_user();
- } else {
- app_info_db = tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db");
- db_path = tzplatform_getenv(TZ_SYS_DB);
- }
-
- // just allow certain users to create the missing directory.
- if (uid_caller == ROOT_UID || uid_caller == uid)
- _mkdir_for_user (db_path, uid, gid);
-
- return app_info_db;
-}
-/**
- * db initialize
- */
-static int __init(uid_t uid)
-{
- int rc;
-
- if (svc_db) {
- _D("Already initialized\n");
- return 0;
- }
-
- rc = sqlite3_open_v2(getUserSvcDB(uid), &svc_db, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
- 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;
- }
- rc = sqlite3_exec(svc_db, QUERY_CREATE_TABLE_APPSVC, NULL, NULL, NULL);
- if(SQLITE_OK!=rc){
- _D("Fail to create tables\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(uid_t uid)
-{
- int rc;
-
- if (app_info_db) {
- _D("Already initialized\n");
- return 0;
- }
-
- rc = sqlite3_open_v2(getUserAppDB(uid), &app_info_db, SQLITE_OPEN_READONLY, NULL);
- 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, uid_t uid)
-{
- char m[BUF_MAX_LEN];
- char u[URI_MAX_LEN];
- char query[QUERY_MAX_LEN];
- char* error_message = NULL;
-
- if(__init(uid)<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);
-
- snprintf(query, QUERY_MAX_LEN, "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, uid_t uid)
-{
- char query[QUERY_MAX_LEN];
- char* error_message = NULL;
-
- if(pkg_name == NULL) {
- _E("Invalid argument: data to delete is NULL\n");
- return -1;
- }
-
- if(__init(uid)<0)
- return -1;
-
- snprintf(query, QUERY_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, uid_t uid)
-{
- 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(uid)<0)
- return 0;
-
- snprintf(query, QUERY_MAX_LEN,
- "select count(*) from appsvc where pkg_name = '%s';", pkg_name);
-
- ret = sqlite3_prepare_v2(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, uid_t uid)
-{
- 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(uid) < 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);
-
- _D("query : %s\n",query);
-
- ret = sqlite3_prepare_v2(svc_db, query, strlen(query), &stmt, NULL);
-
- if ( ret != SQLITE_OK) {
- _E("prepare error(%d)\n", ret);
- 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);
- strncpy(ret_val, (const char *)sqlite3_column_text(stmt, 0),BUF_MAX_LEN-1);
- }
-
- _D("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, uid_t uid)
-{
- 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(uid)<0)
- return 0;
-
- snprintf(query, QUERY_MAX_LEN, "select ac.app_id from package_app_app_control as ac where ac.app_control like '%%%s|%s|%s%%'", op,uri,mime);
- SECURE_LOGD("query : %s\n",query);
-
- ret = sqlite3_prepare_v2(app_info_db, query, strlen(query), &stmt, NULL);
- if ( ret != SQLITE_OK) {
- _E("prepare error, ret = %d, extended = %d %s\n", ret,
- sqlite3_extended_errcode(app_info_db), sqlite3_errmsg(app_info_db));
- return -1;
- }
-
- while (sqlite3_step(stmt) == SQLITE_ROW) {
- str = (char *)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;
-}
-
-int _svc_db_get_list_with_collation(char *op, char *uri, char *mime, GSList **pkg_list, uid_t uid)
-{
- 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(uid)<0)
- return 0;
-
- snprintf(query, QUERY_MAX_LEN, "select ac.app_id from package_app_app_control as ac where ac.app_control='%s|%s|%s' collate appsvc_collation", op,uri,mime);
- SECURE_LOGD("query : %s\n",query);
-
- ret = sqlite3_prepare_v2(app_info_db, query, strlen(query), &stmt, NULL);
-
- if ( ret != SQLITE_OK) {
- _E("prepare error, ret = %d, extended = %d %s\n", ret,
- sqlite3_extended_errcode(app_info_db), sqlite3_errmsg(app_info_db));
- 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;
-}
-
-