/**
* @par Description:
+ * This function sets a appid to launch application based on appsvc.
+ *
+ * @param[in] b bundle object
+ * @param[in] application category
+ *
+ * @return 0 if success, negative value(<0) if fail
+ * @retval APPSVC_RET_OK - success
+ * @retval APPSVC_RET_ERROR - general error
+ * @retval APPSVC_RET_EINVAL - invalid argument(content)
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+ bundle *b = NULL;
+
+ b = bundle_create();
+
+ appsvc_set_operation(b, APPSVC_OPERATION_VIEW);
+ appsvc_set_category(b, "http://tizen.org/category/app/browser");
+}
+ * @endcode
+ *
+ */
+int appsvc_set_category(bundle *b, const char *category);
+
+/**
+ * @par Description:
* This API launch application based on appsvc.
*
* @param[in] b bundle to be passed to callee
/**
* @par Description:
+ * This function gets a application category from bundle.
+ *
+ * @param[in] b bundle object
+ *
+ * @return Pointer for application category string if success, NULL if fail
+ *
+ * @pre None.
+ * @post None.
+ * @see None.
+ * @remarks None.
+ *
+ * @par Sample code:
+ * @code
+#include <appsvc.h>
+
+...
+{
+ char *val;
+ val = appsvc_get_category(b);
+}
+ * @endcode
+ *
+ */
+const char *appsvc_get_category(bundle *b);
+
+/**
+ * @par Description:
* This function gets value from key.
*
* @param[in] b bundle object
#include <libsoup/soup.h>
#include <Ecore_X.h>
#include <Ecore.h>
+#include <iniparser.h>
+#include <pkgmgr-info.h>
#include "appsvc.h"
#include "appsvc_db.h"
char *mime;
char *m_type;
char *s_type;
+ char *category;
int mime_set;
}appsvc_resolve_info_t;
info->uri = (char *)appsvc_get_uri(b);
info->origin_mime = info->mime = (char *)appsvc_get_mime(b);
info->pkgname = (char *)appsvc_get_pkgname(b);
+ info->category = (char *)appsvc_get_category(b);
if(info->uri) {
if(strncmp(info->uri,"/",1) == 0){
return __set_bundle(b, APP_SVC_K_PKG_NAME, pkg_name);
}
+static char* __get_alias_appid(char *appid)
+{
+ char *alias_id = NULL;
+ char *val = NULL;
+ char key_string[MAX_PACKAGE_STR_SIZE+5];
+ dictionary *dic;
+
+ dic = iniparser_load("/usr/share/appsvc/alias.ini");
+
+ if(dic == NULL)
+ return NULL;
+
+ sprintf(key_string, "Alias:%s", appid);
+ val = iniparser_getstr(dic, key_string);
+
+ _D("alias_id : %s", val);
+
+ if(val != NULL) {
+ alias_id = malloc(MAX_PACKAGE_STR_SIZE);
+ strncpy(alias_id, val, MAX_PACKAGE_STR_SIZE-1);
+ }
+
+ iniparser_freedict(dic);
+
+ return alias_id;
+}
+
SLPAPI int appsvc_set_appid(bundle *b, const char *appid)
{
- if(b == NULL){
+ char *alias_id = NULL;
+ int ret;
+
+ if(b == NULL || appid == NULL){
_E("bundle for appsvc_set_appid is NULL");
return APPSVC_RET_EINVAL;
}
- return __set_bundle(b, APP_SVC_K_PKG_NAME, appid);
+ alias_id = __get_alias_appid(appid);
+ if(alias_id == NULL) {
+ ret = __set_bundle(b, APP_SVC_K_PKG_NAME, appid);
+ } else {
+ ret = __set_bundle(b, APP_SVC_K_PKG_NAME, alias_id);
+ free(alias_id);
+ }
+
+ return ret;
+}
+
+SLPAPI int appsvc_set_category(bundle *b, const char *category)
+{
+ if(b == NULL){
+ _E("bundle for appsvc_set_category is NULL");
+ return APPSVC_RET_EINVAL;
+ }
+
+ return __set_bundle(b, APP_SVC_K_CATEGORY, category);
}
static int __get_list_with_condition_mime_extened(char *op, char *uri, char *mime,
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;
+ GSList *iter = NULL;
+ char *list_item = NULL;
+ int match;
+
+ ret = pkgmgrinfo_appinfo_filter_create(&handle);
+ ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_CATEGORY, category);
+
+ tmp_list = *pkg_list;
+ ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, __app_list_cb, &app_list);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+ return -1;
+ }
+ pkgmgrinfo_appinfo_filter_destroy(handle);
+
+ for (iter = *pkg_list; iter != NULL; iter = g_slist_next(iter)) {
+ list_item = (char *)iter->data;
+ g_free(list_item);
+ }
+ g_slist_free(*pkg_list);
+
+ *pkg_list = app_list;
+
+ return 0;
+}
+
SLPAPI int appsvc_run_service(bundle *b, int request_code, appsvc_res_fn cbfunc, void *data)
{
appsvc_resolve_info_t info;
__get_list_with_condition_mime_extened(info.op, info.scheme,
info.mime, info.m_type, info.s_type, &pkg_list);
+ if(info.category) {
+ __get_list_with_category(info.category, &pkg_list);
+ }
+
pkg_count = g_slist_length(pkg_list);
+ _D("pkg_count : %d", pkg_count);
if(pkg_count == 1){
pkgname = (char *)pkg_list->data;
if(pkgname==NULL){
__get_list_with_condition_mime_extened(info.op, info.scheme,
info.mime, info.m_type, info.s_type, &pkg_list);
+
+ if(info.category) {
+ __get_list_with_category(info.category, &pkg_list);
+ }
+
pkg_count = g_slist_length(pkg_list);
+ _D("pkg_count : %d", pkg_count);
if(pkg_count == 1){
pkgname = (char *)pkg_list->data;
return bundle_get_val(b, APP_SVC_K_PKG_NAME);
}
+SLPAPI const char *appsvc_get_category(bundle *b)
+{
+ return bundle_get_val(b, APP_SVC_K_CATEGORY);
+}
+
SLPAPI int appsvc_create_result_bundle(bundle *inb, bundle **outb)
{
int ret = -1;