[JIRA:TT-32] support to app-content-history 26/36326/2 accepted/tizen/tv/20150305.103727 submit/tizen_tv/20150305.095021
authorSoohye Shin <soohye.shin@samsung.com>
Thu, 5 Mar 2015 07:15:27 +0000 (16:15 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Thu, 5 Mar 2015 07:17:00 +0000 (16:17 +0900)
Fix for https://bugs.tizen.org/jira/browse/TT-32

Change-Id: Ida6140e0b3029c92282d77b23d46522be2941ad3
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
CMakeLists.txt
include/engine.h
packaging/org.tizen.homescreen-tv-ref.spec
src/engine.c

index 2ad82f1..e35c566 100644 (file)
@@ -73,6 +73,7 @@ pkg_check_modules(PKGS REQUIRED
                cynara-client
                app-content-favorite
                app-content-provider
+               app-content-history
                capi-appfw-application)
 
 FOREACH(flag ${PKGS_CFLAGS})
index 6ac7ef9..9e74fe0 100644 (file)
@@ -120,5 +120,8 @@ const char *engine_dbar_item_get_content_icon(
 int engine_dbar_item_get_color(struct engine_dbar_item *it,
                int *r, int *g, int *b);
 int engine_dbar_item_launch(struct engine_dbar_item *it);
+int engine_dbar_item_del(struct engine_dbar_item *it,
+               enum engine_dbar_content_type type);
+int engine_dbar_item_del_all(enum engine_dbar_content_type type);
 
 #endif /* __ErGINE_H__ */
index df6b2ae..a5eb74b 100644 (file)
@@ -23,6 +23,7 @@ BuildRequires: pkgconfig(libgum)
 BuildRequires: pkgconfig(cynara-client)
 BuildRequires: pkgconfig(app-content-favorite)
 BuildRequires: pkgconfig(app-content-provider)
+BuildRequires: pkgconfig(app-content-history)
 BuildRequires: edje-bin
 BuildRequires: gettext-devel
 
index 40f7c60..7e0e4eb 100644 (file)
@@ -23,6 +23,7 @@
 #include <ctype.h>
 #include <sys/time.h>
 #include <app-content-favorite.h>
+#include <app-content-history.h>
 #include <gum/gum-user.h>
 #include <gum/gum-user-service.h>
 #include <gum/common/gum-user-types.h>
@@ -1437,6 +1438,15 @@ int engine_bar_item_launch(struct engine_bar_item *it)
                return -1;
        }
 
+       if (!strcmp(it->app, PACKAGE_LIVE_TV))
+               return 0;
+
+       r = app_content_history_add(APP_CH_APPS, it->app);
+       if (r < 0) {
+               _ERR("failed to add history");
+               return -1;
+       }
+
        return 0;
 }
 
@@ -1763,6 +1773,16 @@ static inline int _launch_app(struct engine_dbar_item *it)
                return 0;
        }
 
+       if ((ctnt->type == ENGINE_DBAR_CONTENT_TYPE_BROADCAST) ||
+                               !strcmp(it->actor, PACKAGE_LIVE_TV))
+               return 0;
+
+       r = app_content_history_add(APP_CH_APPS, it->actor);
+       if (r < 0) {
+               _ERR("failed to add history");
+               return 0;
+       }
+
        return 0;
 }
 
@@ -1951,3 +1971,75 @@ int engine_bar_item_swap_pin(struct engine *eng, struct engine_bar_item *it1,
 
        return 0;
 }
+
+int engine_dbar_item_del(struct engine_dbar_item *it,
+               enum engine_dbar_content_type type)
+{
+       bundle *args;
+       const char *svcid;
+       int r;
+
+       if (!it || !it->actor || type > ENGINE_DBAR_CONTENT_TYPE_MAX) {
+               _ERR("Invalid argument");
+               return -1;
+       }
+
+       switch (type) {
+       case ENGINE_DBAR_CONTENT_TYPE_HISTORY:
+               if (!strcmp(it->actor, PACKAGE_LIVE_TV)) {
+                       if (!it->args)
+                               return -1;
+
+                       args = bundle_decode((const bundle_raw*)it->args,
+                                       strlen(it->args));
+                       if (!args) {
+                               _ERR("failed to decode bundle");
+                               return -1;
+                       }
+
+                       svcid = bundle_get_val(args, "svcid");
+                       r = app_content_history_delete(APP_CH_CHANNEL, svcid);
+                       if (r < 0) {
+                               _ERR("failed to delete history");
+                               bundle_free(args);
+                               return -1;
+                       }
+                       bundle_free(args);
+               } else {
+                       r = app_content_history_delete(APP_CH_APPS, it->actor);
+                       if (r < 0) {
+                               _ERR("failed to delete history");
+                               return -1;
+                       }
+               }
+               break;
+       default:
+               break;
+       }
+
+       return 0;
+}
+
+int engine_dbar_item_del_all(enum engine_dbar_content_type type)
+{
+       int r;
+
+       if (type > ENGINE_DBAR_CONTENT_TYPE_MAX) {
+               _ERR("Invalid argument");
+               return -1;
+       }
+
+       switch (type) {
+       case ENGINE_DBAR_CONTENT_TYPE_HISTORY:
+               r = app_content_history_delete_all();
+               if (r < 0) {
+                       _ERR("failed to delete all");
+                       return -1;
+               }
+               break;
+       default:
+               break;
+       }
+
+       return 0;
+}