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__ */
#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>
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;
}
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;
}
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;
+}