summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMake/CMakeLists.txt1
-rwxr-xr-xpackaging/org.tizen.share-panel.spec1
-rw-r--r--src/grid.c26
-rw-r--r--src/list.c49
4 files changed, 71 insertions, 6 deletions
diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt
index c2284a1..ddc568a 100644
--- a/CMake/CMakeLists.txt
+++ b/CMake/CMakeLists.txt
@@ -30,6 +30,7 @@ pkg_check_modules(MENU_PKGS REQUIRED
isf
notification
efl-extension
+ rua
)
FOREACH (flag ${MENU_PKGS_CFLAGS})
diff --git a/packaging/org.tizen.share-panel.spec b/packaging/org.tizen.share-panel.spec
index 013e1bc..75fb19c 100755
--- a/packaging/org.tizen.share-panel.spec
+++ b/packaging/org.tizen.share-panel.spec
@@ -36,6 +36,7 @@ BuildRequires: pkgconfig(feedback)
BuildRequires: pkgconfig(isf)
BuildRequires: pkgconfig(notification)
BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(rua)
%description
Description: Share Panel
diff --git a/src/grid.c b/src/grid.c
index 580c36f..f7c808a 100644
--- a/src/grid.c
+++ b/src/grid.c
@@ -130,8 +130,7 @@ static void __del(void *data, Evas_Object *obj)
int _app_control_launch(item_s *item)
{
- retv_if(!item->caller_control, APP_CONTROL_ERROR_INVALID_PARAMETER);
-
+ retv_if(!item->caller_control, FAIL);
int ret = APP_CONTROL_ERROR_NONE;
bundle *control_bundle;
@@ -139,11 +138,30 @@ int _app_control_launch(item_s *item)
ret = app_control_export_as_bundle(item->caller_control, &control_bundle);
retv_if(ret != APP_CONTROL_ERROR_NONE, FAIL);
+ ret = bundle_add_str(control_bundle, AUL_SVC_K_RUA_STAT_CALLER, "share-panel");
+ if (ret != BUNDLE_ERROR_NONE)
+ {
+ bundle_free(control_bundle);
+ return FAIL;
+ }
+
+ ret = bundle_add_str(control_bundle, AUL_SVC_K_RUA_STAT_TAG, item->appid);
+ if (ret != BUNDLE_ERROR_NONE)
+ {
+ bundle_free(control_bundle);
+ return FAIL;
+ }
+
ret = aul_forward_app(item->appid, control_bundle);
+ if (ret < 0)
+ {
+ bundle_free(control_bundle);
+ return FAIL;
+ }
bundle_free(control_bundle);
- return ret;
+ return OK;
}
static void __item_selected(void *data, Evas_Object *obj, void *event_info)
@@ -166,7 +184,7 @@ static void __item_selected(void *data, Evas_Object *obj, void *event_info)
ret = _app_control_launch(item_info);
- if (ret < 0) {
+ if (ret == FAIL) {
_E("Fail to launch app(%d)", ret);
share_panel_reply(item_info->share_panel, false);
} else
diff --git a/src/list.c b/src/list.c
index d7d7029..893acbd 100644
--- a/src/list.c
+++ b/src/list.c
@@ -23,7 +23,12 @@
#include "share_panel_internal.h"
#include "log.h"
#include "grid.h"
+#include <rua_stat.h>
+typedef struct {
+ Eina_List *input;
+ Eina_List *output;
+} sort_context_t;
static bool __app_control_matched_cb(app_control_h service, const char *appid, void *user_data)
{
@@ -307,7 +312,7 @@ static void __make_applist(share_panel_h share_panel, Eina_List *matchlist, Eina
_D("icon_path : [%s]", app_s->icon);
app_s->share_panel = share_panel;
- *applist = eina_list_sorted_insert(*applist, __applist_compare, app_s);
+ *applist = eina_list_append(*applist, app_s);
}
}
@@ -331,6 +336,46 @@ static int check_mime(app_control_h control, char* operation_type)
return OK;
}
+static int __rua_stat_tag_iter_cb(const char *rua_stat_tag, void *data)
+{
+ sort_context_t *ctx = data;
+ item_s *item;
+ Eina_List *l, *ln;
+
+ _D("Rua tag: %s", rua_stat_tag);
+ EINA_LIST_FOREACH_SAFE(ctx->input, l, ln, item) {
+ if (item->appid && !strcasecmp(rua_stat_tag, item->appid)) {
+ ctx->output = eina_list_append(ctx->output, item);
+ ctx->input = eina_list_remove_list(ctx->input, l);
+ break;
+ }
+ }
+
+ return 0;
+}
+
+static Eina_List *_list_sort(Eina_List *items)
+{
+ sort_context_t context;
+ int err;
+
+ context.input = items;
+ context.output = NULL;
+
+ // first sort using rua tags names
+ err = rua_stat_get_stat_tags("share-panel", __rua_stat_tag_iter_cb, &context);
+ if (err != 0) {
+ // this may return -1 once when db is not created.
+ _E("rua_stat_get_stat_tags failed[%d]: %s", err, get_error_message(err));
+ }
+
+ // secondly sort alphabetically
+ context.output = eina_list_merge(
+ context.output, eina_list_sort(context.input, 0, __applist_compare));
+
+ return context.output;
+}
+
Eina_List *_list_create(share_panel_h share_panel)
{
Eina_List *matchlist = NULL; // List of ID's of matched apps
@@ -364,7 +409,7 @@ Eina_List *_list_create(share_panel_h share_panel)
free(data);
}
- return applist;
+ return _list_sort(applist);
}