コード例 #1
0
static void
grl_raitv_source_browse (GrlSource *source,
                         GrlSourceBrowseSpec *bs)
{
  RaitvOperation *op = g_slice_new0 (RaitvOperation);

  const gchar *container_id;
  GRL_DEBUG ("%s: %s", __FUNCTION__, grl_media_get_id (bs->container));
  container_id = grl_media_get_id (bs->container);

  op->source       = g_object_ref (source);
  op->cancellable  = g_cancellable_new ();
  op->length        = grl_operation_options_get_count (bs->options);
  op->operation_id = bs->operation_id;
  op->container_id = container_id;
  op->callback     = bs->callback;
  op->user_data    = bs->user_data;
  op->skip	   = grl_operation_options_get_skip (bs->options);
  op->count	   = op->length;
  op->offset       = 0;

  grl_operation_set_data_full (bs->operation_id, op, (GDestroyNotify) raitv_operation_free);

  RaitvMediaType type = classify_media_id (container_id);
  switch (type)
    {
    case RAITV_MEDIA_TYPE_ROOT:
      produce_from_directory (root_dir, root_dir_size, op, type);
      break;
    case RAITV_MEDIA_TYPE_POPULARS:
      produce_from_directory (themes_dir,
                              root_dir[ROOT_DIR_POPULARS_INDEX].count, op, RAITV_MEDIA_TYPE_POPULAR_THEME);
      break;
    case RAITV_MEDIA_TYPE_RECENTS:
      produce_from_directory (themes_dir,
                              root_dir[ROOT_DIR_RECENTS_INDEX].count, op, RAITV_MEDIA_TYPE_RECENT_THEME);
      break;
    case RAITV_MEDIA_TYPE_POPULAR_THEME:
      produce_from_popular_theme (op);
      break;
    case RAITV_MEDIA_TYPE_RECENT_THEME:
      produce_from_recent_theme (op);
      break;
    case RAITV_MEDIA_TYPE_VIDEO:
    default:
      g_assert_not_reached ();
      break;
    }

}
コード例 #2
0
/* Returns: (transfer none) */
static GCancellable *
resolve_data_ensure_cancellable (ResolveData *resolve_data)
{
  GCancellable *cancellable;

  cancellable = grl_operation_get_data (resolve_data->rs->operation_id);

  if (cancellable)
    return cancellable;

  cancellable = g_cancellable_new ();
  /* The operation owns the cancellable */
  grl_operation_set_data_full (resolve_data->rs->operation_id,
                               cancellable,
                               (GDestroyNotify) g_object_unref);
  return cancellable;
}
コード例 #3
0
ファイル: grl-bliptv.c プロジェクト: victortoso/grilo-plugins
static void
grl_bliptv_source_search (GrlSource *source,
                          GrlSourceSearchSpec *ss)
{
  BliptvOperation *op = g_slice_new0 (BliptvOperation);
  gchar *url;
  gint count = grl_operation_options_get_count (ss->options);
  guint page_number;
  guint page_offset;

  grl_paging_translate (grl_operation_options_get_skip (ss->options),
                        count,
                        MAX_ELEMENTS,
                        NULL,
                        &page_number,
                        &page_offset);

  op->source       = g_object_ref (source);
  op->cancellable  = g_cancellable_new ();
  op->count        = count;
  op->skip         = page_offset;
  op->page         = page_number;
  op->url          = g_strdup_printf (BLIPTV_SEARCH, ss->text);
  op->operation_id = ss->operation_id;
  op->callback     = ss->callback;
  op->user_data    = ss->user_data;


  grl_operation_set_data_full (ss->operation_id, op, (GDestroyNotify) bliptv_operation_free);

  url = g_strdup_printf (op->url, page_number);

  GRL_DEBUG ("Starting search request for id=%u : '%s'",
             ss->operation_id, ss->text);

  grl_net_wc_request_async (GRL_BLIPTV_SOURCE (source)->priv->wc,
                            url,
                            op->cancellable,
                            call_raw_async_cb,
                            op);
  g_free (url);
}
コード例 #4
0
static void
grl_raitv_source_search (GrlSource *source,
                         GrlSourceSearchSpec *ss)
{
  RaitvOperation *op = g_slice_new0 (RaitvOperation);

  op->source       = g_object_ref (source);
  op->cancellable  = g_cancellable_new ();
  op->length        = grl_operation_options_get_count (ss->options);
  op->operation_id = ss->operation_id;
  op->callback     = ss->callback;
  op->user_data    = ss->user_data;
  op->skip	   = grl_operation_options_get_skip (ss->options);
  op->count	   = op->length;
  op->offset       = 0;
  op->text	   = ss->text;

  grl_operation_set_data_full (ss->operation_id, op, (GDestroyNotify) raitv_operation_free);

  g_raitv_videos_search(op);
}
コード例 #5
0
static void
grl_raitv_source_resolve (GrlSource *source,
                          GrlSourceResolveSpec *rs)
{
  gchar *urltarget;
  GrlRaitvSource *self = GRL_RAITV_SOURCE (source);
  RaitvOperation *op;
  RaitvMediaType mediatype;

  GRL_DEBUG ("Starting resolve source: url=%s",grl_media_get_url (rs->media));

  if (!GRL_IS_MEDIA_VIDEO (rs->media) && !GRL_IS_MEDIA_BOX (rs->media)) {
    rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL);
    return;
  }

  mediatype = classify_media_id (grl_media_get_id (rs->media));
  switch (mediatype) {
  case RAITV_MEDIA_TYPE_ROOT:
    rs->media = produce_container_from_directory (rs->media, NULL, 0, mediatype);
    break;
  case RAITV_MEDIA_TYPE_POPULARS:
    rs->media = produce_container_from_directory (rs->media, root_dir, ROOT_DIR_POPULARS_INDEX, mediatype);
    break;
  case RAITV_MEDIA_TYPE_RECENTS:
    rs->media = produce_container_from_directory (rs->media, root_dir, ROOT_DIR_RECENTS_INDEX, mediatype);
    break;
  case RAITV_MEDIA_TYPE_POPULAR_THEME:
  case RAITV_MEDIA_TYPE_RECENT_THEME:
    rs->media = produce_container_from_directory (rs->media,
                                                  themes_dir,
                                                  get_theme_index_from_id (grl_media_get_id (rs->media)),
                                                  mediatype);
    break;
  case RAITV_MEDIA_TYPE_VIDEO:
    op = g_slice_new0 (RaitvOperation);
    op->source       = g_object_ref (source);
    op->cancellable  = g_cancellable_new ();
    op->operation_id = rs->operation_id;
    op->resolveCb    = rs->callback;
    op->user_data    = rs->user_data;
    op->media	      = rs->media;

    grl_operation_set_data_full (rs->operation_id, op, (GDestroyNotify) raitv_operation_free);

    urltarget = g_strdup_printf ("http://www.rai.tv/dl/RaiTV/programmi/media/%s.html",
                                 grl_media_get_id(rs->media));

    GRL_DEBUG ("Opening '%s'", urltarget);

    grl_net_wc_request_async (self->priv->wc,
                              urltarget,
                              op->cancellable,
                              proxy_call_resolve_grlnet_async_cb,
                              op);

    g_free(urltarget);
    return;
  }
  rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL);
  return;

  if ( grl_media_get_url (rs->media) != NULL) {
    rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL);
    return;
  }

  op = g_slice_new0 (RaitvOperation);
  op->source       = g_object_ref (source);
  op->cancellable  = g_cancellable_new ();
  op->operation_id = rs->operation_id;
  op->resolveCb     = rs->callback;
  op->user_data    = rs->user_data;
  op->media	   = rs->media;

  grl_operation_set_data_full (rs->operation_id, op, (GDestroyNotify) raitv_operation_free);

  urltarget = g_strdup_printf("%s/%s.html","http://www.rai.tv/dl/RaiTV/programmi/media",grl_media_get_id(rs->media));

  GRL_DEBUG ("Opening '%s'", urltarget);

  grl_net_wc_request_async (self->priv->wc,
                            urltarget,
                            op->cancellable,
                            proxy_call_resolve_grlnet_async_cb,
                            op);

  g_free(urltarget);
}