diff options
author | Lukasz Stanislawski <l.stanislaws@samsung.com> | 2016-11-24 13:26:51 +0100 |
---|---|---|
committer | Lukasz Stanislawski <l.stanislaws@samsung.com> | 2016-11-24 14:14:51 +0100 |
commit | 8ad91ade576797f01c8a40b329d7b3c71b3bdfbf (patch) | |
tree | a331d1cbf92e62b6b1ec296bde3b0ec4f3960875 | |
parent | cd63e22cd996e0c74b00109f231111cb2132384c (diff) | |
download | share-panel-8ad91ade576797f01c8a40b329d7b3c71b3bdfbf.tar.gz share-panel-8ad91ade576797f01c8a40b329d7b3c71b3bdfbf.tar.bz2 share-panel-8ad91ade576797f01c8a40b329d7b3c71b3bdfbf.zip |
list: implement sorting using rua informationsubmit/tizen/20161124.152656
Use information obtained from rua_stat module to sort
list items. The patch introduces two modifications:
1. User rua_tag for change sorting order
2. Add information about chosen app to bundle in order
to update rua statistics.
Change-Id: Ie29cde379738e315f7353caeed64b7921aa3fad2
-rw-r--r-- | CMake/CMakeLists.txt | 1 | ||||
-rwxr-xr-x | packaging/org.tizen.share-panel.spec | 1 | ||||
-rw-r--r-- | src/grid.c | 26 | ||||
-rw-r--r-- | src/list.c | 49 |
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 @@ -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 @@ -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); } |