Add favorite list on action menu
[profile/tv/apps/native/air_livetv.git] / src / tv.c
index 9685aa2..418d579 100644 (file)
--- a/src/tv.c
+++ b/src/tv.c
 #include <app_debug.h>
 #include <app_contents.h>
 
+#include <tv_service_proxy.h>
+#include <tv_service_proxy_epg.h>
+
 #include <glib.h>
 #include <glib-object.h>
 
 #include "define.h"
 #include "tv.h"
-#include "tv_service.h"
 
 #define DEFAULT_SERVICE 1
 
@@ -490,6 +492,41 @@ Eina_List *tv_channel_get_list()
        return channel_list;
 }
 
+/**
+ * Gets a favorite channel list.
+ *
+ * @return Favorite channel list, or NULL if fails
+ */
+Eina_List *tv_channel_get_favorite_list()
+{
+       GList *tvs_list = NULL;
+       Eina_List *channel_list = NULL;
+       TvServiceChannel *tvs_data = NULL;
+       const struct tv_channel_info *channel_info;
+       int r, i;
+
+       r = tv_service_get_channel_list(
+                       TV_SERVICE_CHANNEL_MODE_FAVORITE,
+                       TV_SERVICE_ANTENNA_TYPE_ALL, &tvs_list);
+       if (r != TVS_ERROR_OK) {
+               _ERR("failed to get channel list");
+               return NULL;
+       }
+
+       for (i = 0; i < g_list_length(tvs_list); i++) {
+               tvs_data = (TvServiceChannel *) g_list_nth_data(tvs_list, i);
+               if (tvs_data) {
+                       channel_info = _tv_channel_get_info(tvs_data);
+                       if (channel_info)
+                               channel_list = eina_list_append(channel_list,
+                                               channel_info);
+                       free(tvs_data);
+               }
+       }
+
+       return channel_list;
+}
+
 TvServiceFilterNode *_tv_channel_get_filter(
                TvServiceChannelDataAttr attribute, int type, void *data)
 {
@@ -666,7 +703,7 @@ int tv_channel_tune(void)
        }
 
        r = tv_service_live_get_last_channel(&service_id);
-       if (r < 0) {
+       if (r < 0 || service_id < 1) {
                _ERR("failed to get current service id");
                service_id = DEFAULT_SERVICE;
        }
@@ -1021,30 +1058,6 @@ void tv_signal_cb_set(void (*cb)(void *data, int is_signal), void *data)
 }
 
 /**
- * Sets window id for tv overlay.
- *
- * @param window_id The window id to overlay
- * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
- */
-int tv_overlay_set(void *window_id)
-{
-       int r;
-
-       if (!g_tv_info.live_svc) {
-               _ERR("failed to get live service");
-               return -1;
-       }
-
-       r = tv_service_live_set_window_overlay(g_tv_info.live_svc, window_id);
-       if (r < 0) {
-               _ERR("failed to set overlay");
-               return -1;
-       }
-
-       return 0;
-}
-
-/**
  * Destory the tv service handles.
  *
  * @return If the operation was sucessful 0 is returned; otherwise negative value is returned
@@ -1053,12 +1066,8 @@ int tv_destroy(void)
 {
        int r;
 
-       if (g_tv_info.live_svc) {
-               r = tv_service_live_destroy(g_tv_info.live_svc);
-               if (r != TVS_ERROR_OK)
-                       _ERR("failed to destroy live service");
+       if (g_tv_info.live_svc)
                g_tv_info.live_svc = NULL;
-       }
 
        r = tv_service_channel_info_destroy();
        if (r < 0)
@@ -1121,6 +1130,14 @@ err:
  */
 int tv_pause(void)
 {
+       int r;
+
+       if (g_tv_info.live_svc) {
+               r = tv_service_live_tune_pause(g_tv_info.live_svc);
+               if (r != TVS_ERROR_OK)
+                       _ERR("failed to pause live service");
+       }
+
        return 0;
 }
 
@@ -1140,10 +1157,17 @@ int tv_resume(void)
 {
        int r;
 
-       if (g_tv_info.live_svc)
-               return 0;
+       if (!g_tv_info.live_svc) {
+               r = tv_service_live_create(&g_tv_info.live_svc);
+               if (r != TVS_ERROR_OK) {
+                       _ERR("failed to create live service");
+                       goto err;
+               } else {
+                       return 1;
+               }
+       }
 
-       r = tv_service_live_create(&g_tv_info.live_svc);
+       r = tv_service_live_tune_resume(g_tv_info.live_svc);
        if (r != TVS_ERROR_OK) {
                _ERR("failed to create live service");
                goto err;
@@ -1156,7 +1180,7 @@ int tv_resume(void)
                goto err;
        }
 
-       return 1;
+       return 0;
 
 err:
        tv_destroy();