Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
static void
grl_vimeo_source_search (GrlSource *source,
                         GrlSourceSearchSpec *ss)
{
  SearchData *sd;
  GError *error;
  gint per_page;
  GVimeo *vimeo = GRL_VIMEO_SOURCE (source)->priv->vimeo;
  guint skip = grl_operation_options_get_skip (ss->options);
  gint count = grl_operation_options_get_count (ss->options);

  if (!ss->text) {
    /* Vimeo does not support searching all */
    error = g_error_new (GRL_CORE_ERROR,
                         GRL_CORE_ERROR_SEARCH_NULL_UNSUPPORTED,
                         _("Failed to search: %s"),
                         _("non-NULL search text is required"));
    ss->callback (ss->source, ss->operation_id, NULL, 0, ss->user_data, error);
    g_error_free (error);
    return;
  }

  sd = g_slice_new0 (SearchData);
  sd->vimeo = vimeo;
  sd->get_url = (g_list_find (ss->keys,
                              GRLKEYID_TO_POINTER (GRL_METADATA_KEY_URL)) != NULL);

  /* Compute items per page and page offset */
  grl_paging_translate (skip,
                        count,
                        MAX_ELEMENTS,
                        (guint *) &per_page,
                        (guint *) &(sd->page),
                        (guint *) &(sd->offset));

  g_vimeo_set_per_page (vimeo, per_page);
  sd->ss = ss;

  g_vimeo_videos_search (vimeo, ss->text, sd->page, search_cb, sd);
}